The following code shows you how to sum the all elements of array without using loop. For example your array contains {1,2, 3, 4, 5}, if use loop strategy : going through each index and sum the elements but through LINQ Sum() method, without going into loop headache.See the code below.
Dim number() As Integer = {1, 3, 2, 5, 7}
Dim query = number.Sum()
Console.WriteLine(query)
Output of the program is:
18
0 comments:
Post a Comment