+92 332 4229 857 99ProjectIdeas@Gmail.com

LINQ Average() Method (Vb.net)



The following code shows you how to count average of array elements without loop. Typically we have been counting average through loop and going through every array index add it and then divide it with total number of indexes. But here we can get average of array elements through LINQ Average() method. See the code below.





Dim intArr As Integer() = {2, 1, 2, 3, 7, 5, 10, 9}

Dim query = intArr.Average()

Console.Write(query.ToString())

Output of the program is:
4.875 
 

0 comments: