OKIEWARDOYO

VISUAL C# No.44 2

Jul 15th, 2014
3,516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LinqToArray
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //data source
  14.             int[] numbers = new int[10] {1,2,3,4,5,6,7,8,9,10};
  15.  
  16.             //query creation
  17.             var queryNumber = from num in numbers
  18.                               where (num % 2) == 0
  19.                               select num;
  20.  
  21.             //query execution
  22.             foreach (int num in queryNumber)
  23.             {
  24.                 Console.WriteLine(num);
  25.             }
  26.  
  27.             Console.ReadKey();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment