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 + " ");
4 1 4 9 49 25 100 81
0 comments:
Post a Comment