09a51b09a1b0f94323b643a12af67f85
43.SkipWhile

LINQ SkipWhile 简介

如果指定的条件为 true,则跳过序列中的元素,然后返回剩余的元素。

LINQ SkipWhile 代码示例

/****************************************************************************
 * http://sikiedu.com liangxie
 ****************************************************************************/

using System.Linq;
using UnityEngine;

namespace UniRxLesson
{
    public class LINQSkipWhileExample : MonoBehaviour
    {

        private void Start()
        {
            int[] grades = {59, 82, 70, 56, 92, 98, 85};

            var lowerGrades =
                grades
                    .OrderByDescending(grade => grade)
                    .SkipWhile(grade => grade >= 80);

            foreach (var grade in lowerGrades)
            {
                Debug.Log(grade);
            }
        }
    }
}

输出结果为:

```cs
70

top Created with Sketch.