So basically what i'm trying to do is calculate the average of all the Stop Watch times that my for loop produces and out put it to the Console. i know how to take an average but i dont know how to apply it to Stopwatch times. Please help?
for (int index = 0; index < iterations; index++)
{
// loop to generate an array of random numbers
for (int count = 0; count < arrayOfInts.Length; count++)
{
arrayOfInts[count] = r.Next(numitems);
}
// a random array has been created start the clock and sort it
Stopwatch elpased = new Stopwatch();
elpased.Start();
selectionSort(arrayOfInts);
elpased.Stop();
if (iterations == iterations)
{
var average = elpased.Elapsed;
Console.WriteLine ("Time for ___ sort to complete: " + elpased.Elapsed.ToString ());
}
}
Console.ReadLine();
}
This is what i have so far.