Below is function to calculate mean from an array using c#. This is static function so you can make use of this to get Average of an array.
Below function will accept Array of double and you the mean or average of that array
public static double GetMean(double Values)
double mean = 0;foreach (double average in Values)
mean += average;
mean /= Values.Length;return mean;
Vb.NET code sample
Public Shared Function GetMean(ByVal Values As Double()) As Double
Dim mean As Double = 0For Each average As Double In Values
mean += average
Return meanEnd Function
mean /= Values.Length
Hope this will help all who want to calculate mean or average from an array.