CODEKILLER

반응형

Linq - Enumerable.Take 출력

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

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

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

        Console.WriteLine("상위 3개 등급 : ");
        foreach (int grade in topThreeGrades)
        {
            Console.WriteLine(grade);
        }

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

공유하기

facebook twitter kakaoTalk kakaostory naver band