84. 표준쿼리연산자
using System;
using System.Collections.Generic;
using System.Linq;
public class 표준쿼리연산자
{
public static bool EvenNum(int x) { return (x % 2 == 0); }
public static void Main()
{
//[1] Input
int[] data = {3, 5, 4, 2, 1};
//[2] Process
var q =
//from d in data select d; // 전체
//from d in data where d % 2 == 0 orderby d select d; // //[1] 쿼리식 //짝수
//data.Where(EvenNum); //[2] (Where라는 확장)메서드를 통해서 짝수를 구함
//data.Where(delegate(int x) { return (x % 2 == 0); }); //[3] 무명메서드를 통해서 짝수를 구함
data.Where(x => x % 2 == 0); //[4] 람다식을 이용해서 짝수를 구함
//[3] Output
foreach (var item in q)
{
Console.WriteLine("{0}", item);
}
}
}
/*
Where라는 이름의 확장메서드를 표준쿼리연산자라고 한다.
(--> 여기서는 Where메서드가 쩜(.)을 찍었을 때 다양한 속성이 나오는 메서드임. )
*/