CODEKILLER

반응형

Linq - Enumerable.TakeWhile 출력.
Linq - Enumerable.TakeWhile 출력.

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

        string[] fruits = { "apple", "passionfruit", "banana", "mango",
                      "orange", "blueberry", "grape", "strawberry" };

        IEnumerable<string> query = fruits.TakeWhile((fruit, index) => fruit.Length >= index);

        foreach (string fruit in query)
        {
            Console.WriteLine(fruit);
        }

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

공유하기

facebook twitter kakaoTalk kakaostory naver band