using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; namespace ConsoleApplication1 { /// /// My unbelievably awesome, non-generic, Program-class. /// --------- /// Notes: /// ctrl + m, ctrl + (l,o) : Collapse, expand code /// class Program { /// /// This method defines the entry point of each csharp program. Kinda funny, eh? :) /// /// The console args. static void Main(string[] args) { const int NUM_ITEMS = 1000000; List list = new List(NUM_ITEMS); Stopwatch stopwatch = new Stopwatch(); { // Insert stopwatch.Start(); for (int i = 0; i < NUM_ITEMS; ++i) { list.Add(i); } stopwatch.Stop(); Console.WriteLine("Insert dt:" + stopwatch.ElapsedMilliseconds); } stopwatch.Reset(); { // Read long sum = 0; stopwatch.Start(); for (int i = 0; i < NUM_ITEMS; ++i) { sum += list[i]; } stopwatch.Stop(); Console.WriteLine("Read dt:" + stopwatch.ElapsedMilliseconds); Console.WriteLine("Read sum: " + sum); } } } }