+92 332 4229 857 99ProjectIdeas@Gmail.com

LINQ Select() Method (C#.net)



LINQ Select() Method (C#.net):
The following code shows you how to square the each element in array through LINQ Select() method.


Code


int[] arr1 = { 2, 1, 2, 3, 7, 5, 10, 9 };


var query = arr1.Select(number => number * number);

    foreach (var item in query)
           Console.Write(item + " ");

Output of the program is:
4 1 4 9 49 25 100 81 

0 comments: