SkipWhile() 메서드를 사용하여 배열의 요소를 무시하고 나머지 요소를 반환합니다.
다음은 우리의 배열입니다 -
int[] marks = { 45, 88, 55, 90, 95, 85 }; 이제 60보다 크거나 같은 요소는 건너뛰도록 합시다. Lambda 식을 사용하여 설정한 조건입니다.
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >= 60);
예시
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] marks = { 45, 88, 55, 90, 95, 85 };
// skips elements above 60
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >= 60);
// displays rest of the elements
Console.WriteLine("Skipped marks > 60...");
foreach (int res in selMarks) {
Console.WriteLine(res);
}
}
} 출력
Skipped marks > 60... 55 45