The following code shows you how to square the each element in array through LINQ Select() method.
Dim intArr As Integer() = {2, 1, 2, 3, 7, 5, 10, 9}
Dim query = intArr.Select(Function(x) x * x)
For Each i In query
Console.Write(i.ToString() & " ")
Next
Output of the program is:
4 1 4 9 49 25 100 81
0 comments:
Post a Comment