using System;
using System.Linq;
class Program
{
static void Main()
{
int[] array = new int[6] { 1, 2, 3, 4, 5, 6 };
var qry =
from num in array
where (num % 2) == 0
select num;
Console.WriteLine("Even Numbers are");
foreach (int even in qry)
{
Console.Write("{0,1} ", even);
}
Console.ReadKey();
}
}
|
Imports System.Linq
Class Program
Private Shared Sub Main()
Dim array As Integer() = New Integer(6) {1, 2, 3, 4, 5, 6}
Dim qry = From num In array
Where (num Mod 2) = 0
Select num
Console.WriteLine("Even Numbers are")
For Each even As Integer In qry
Console.Write("{0,1} ", even)
Next
Console.ReadKey()
End Sub
End Class
|