Use LINQ's Min, Max, and Average extension methods to get the minimum, maximum, and average values in an array in C#

// Make some random values.Download example
private void Form1_Load(object sender, EventArgs e)
{
const int num_values = 50;
Random rand = new Random();
int[] values = new int[num_values];
for (int i = 0; i < num_values; i++)
{
values[i] = rand.Next(0, 10000);
}
// Display the values.
lstValues.DataSource = values;
// Use LINQ extention methods to get
// the minimum, maximum, and average values.
txtMin.Text = values.Min().ToString();
txtMax.Text = values.Max().ToString();
txtAve.Text = values.Average().ToString();
}
-->
Comments