{
class Program
{
static void Main(string[] args)
{
// The Three Parts of a LINQ Query:
// 1. Data source.
int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };
int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };
// 2. Query creation.
// numQuery is an IEnumerable
var numquery =
from num in numbers
where (num % 2) == 0
select num;
var numquery =
from num in numbers
where (num % 2) == 0
select num;
//3. Query Execution
foreach (int num in numquery)
{
Console.Write("{0,1}", num);
}
}
}
}
No comments:
Post a Comment