dictionary

C#. Int array vs. ArrayList vs. Dictionary

private static void TestIntArray() { int [] array = new int[1000]; for (int i = 0; i < 1000; i++) array[i] = i; } private static void TestArrayList() { ArrayList array = new ArrayList(); for (int i = 0; i < 1000; i++) array.Add(i); } // Code.... long start = DateTime.Now.Ticks; TestIntArray(); long end = DateTime.Now.Ticks; Console.WriteLine("Time with int array: {0}", end - start); long start2 = DateTime.Now.Ticks; TestArrayList(); long end2 = DateTime.Now.Ticks; Console.WriteLine("Time with ArrayList array: {0}", end2 - start2);
The result:
Time