public class Example
{
public static void Main()
{
Console.Write("<< Linq - Queryable.TakeWhile 출력 예제 >> \n");
string[] fruits = { "apple", "banana", "mango", "orange",
"passionfruit", "grape" };
// orange를 찿을때까지 출력.
IEnumerable<string> query =
fruits.AsQueryable()
.TakeWhile(fruit => String.Compare("orange", fruit, true) != 0);
foreach (string fruit in query)
Console.WriteLine(fruit);
Console.WriteLine(System.Environment.NewLine);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}