CODEKILLER

반응형

Linq - Queryable.Take 출력.
Linq - Queryable.Take 출력.

public class Example
{
    public static void Main()
    {
        Console.Write("<< Linq - Queryable.Take 출력 예제 >> \n");

        int[] grades = { 59, 82, 70, 56, 92, 98, 85 };

        IEnumerable<int> topThree =
            grades.AsQueryable().OrderByDescending(grade => grade).Take(3);

        Console.WriteLine("상위 3개 등급은 :");
        foreach (int grade in topThree)
            Console.WriteLine(grade);

        Console.WriteLine(System.Environment.NewLine);
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
    }
}
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band