using System; class MainClass { public static void Main() { DateTime start = DateTime.Now; long total = 0; for (int count = 0; count < 1000000; count++) { total += count; } TimeSpan timeTaken = DateTime.Now - start; Console.WriteLine("Milliseconds = " + timeTaken.Milliseconds); Console.WriteLine("total = " + total); } }
Milliseconds = 0 total = 499999500000