How to pass method name as a parmeter? : <p>I'm looking for a way to make my code shorter. Since a big part of my code is repeatable, is there any way to pass a sub method name as a parmeter?</p>

<p>Here is a some bigger part to make my problem some more clear:</p>

<pre><code>Random rnd = new Random(Guid.NewGuid().GetHashCode());
        int[] ArrayRandom = new int[200000];
        for (int j = 0; j &lt; ArrayRandom.Length; j++) ArrayRandom[j] = rnd.Next(int.MaxValue);

        Console.WriteLine("\nInsertionSort\nARRAY SIZE:\t TIME [ms]:");
        for (int u = 50000; u &lt;= 200000; u += 10000)
        {
            int[] TestArray = new int[u];
            Array.Copy(ArrayRandom, TestArray, u);
            double ElapsedSeconds;
            long ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
            for (int n = 0; n &lt; (NIter + 1 + 1); ++n)  
            {
                long StartingTime = Stopwatch.GetTimestamp();
                InsertionSort(TestArray);
                long EndingTime = Stopwatch.GetTimestamp();
                IterationElapsedTime = EndingTime - StartingTime;
                ElapsedTime += IterationElapsedTime;
                if (IterationElapsedTime &lt; MinTime) MinTime = IterationElapsedTime;
                if (IterationElapsedTime &gt; MaxTime) MaxTime = IterationElapsedTime;
            }
            ElapsedTime -= (MinTime + MaxTime);
            ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
            Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
        }

        Console.WriteLine("\nSelectionSort\nARRAY SIZE:\t TIME [ms]:");
        for (int u = 50000; u &lt;= 200000; u += 10000)
        {
            int[] TestArray = new int[u];
            Array.Copy(ArrayRandom, TestArray, u);

            double ElapsedSeconds;
            long ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
            for (int n = 0; n &lt; (NIter + 1 + 1); ++n)  
            {
                long StartingTime = Stopwatch.GetTimestamp();
                SelectionSort(TestArray);
                long EndingTime = Stopwatch.GetTimestamp();
                IterationElapsedTime = EndingTime - StartingTime;
                ElapsedTime += IterationElapsedTime;
                if (IterationElapsedTime &lt; MinTime) MinTime = IterationElapsedTime;
                if (IterationElapsedTime &gt; MaxTime) MaxTime = IterationElapsedTime;
            }
            ElapsedTime -= (MinTime + MaxTime);
            ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
            Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
        }
        Console.WriteLine("\nCoctailSort\nARRAY SIZE:\t TIME [ms]:");
        for (int u = 50000; u &lt;= 200000; u += 10000)
        {
            int[] TestArray = new int[u];
            Array.Copy(ArrayRandom, TestArray, u);

            double ElapsedSeconds;
            long ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
            for (int n = 0; n &lt; (NIter + 1 + 1); ++n)  
            {
                long StartingTime = Stopwatch.GetTimestamp();
                CocktailSort(TestArray);
                long EndingTime = Stopwatch.GetTimestamp();
                IterationElapsedTime = EndingTime - StartingTime;
                ElapsedTime += IterationElapsedTime;
                if (IterationElapsedTime &lt; MinTime) MinTime = IterationElapsedTime;
                if (IterationElapsedTime &gt; MaxTime) MaxTime = IterationElapsedTime;
            }
            ElapsedTime -= (MinTime + MaxTime);
            ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
            Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
        }
        Console.WriteLine("\nHeapSort\nARRAY SIZE:\t TIME [ms]:");
        for (int u = 50000; u &lt;= 200000; u += 10000)
        {
            int[] TestArray = new int[u];
            Array.Copy(ArrayRandom, TestArray, u);

            double ElapsedSeconds;
            long ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
            for (int n = 0; n &lt; (NIter + 1 + 1); ++n)  
            {
                long StartingTime = Stopwatch.GetTimestamp();
                HeapSort(TestArray);
                long EndingTime = Stopwatch.GetTimestamp();
                IterationElapsedTime = EndingTime - StartingTime;
                ElapsedTime += IterationElapsedTime;
                if (IterationElapsedTime &lt; MinTime) MinTime = IterationElapsedTime;
                if (IterationElapsedTime &gt; MaxTime) MaxTime = IterationElapsedTime;
            }
            ElapsedTime -= (MinTime + MaxTime);
            ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
            Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
        }
</code></pre>

<p>As You see, that what is changing is a sort method name. Basicly I want to change, this:</p>

<pre><code>Console.WriteLine("\nInsertionSort\nARRAY SIZE:\t TIME [ms]:");
    for (int u = 50000; u &lt;= 200000; u += 10000)
    {
        int[] TestArray = new int[u];
        Array.Copy(ArrayRandom, TestArray, u);
        double ElapsedSeconds;
        long ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
        for (int n = 0; n &lt; (NIter + 1 + 1); ++n)  
        {
            long StartingTime = Stopwatch.GetTimestamp();
            InsertionSort(TestArray);
            long EndingTime = Stopwatch.GetTimestamp();
            IterationElapsedTime = EndingTime - StartingTime;
            ElapsedTime += IterationElapsedTime;
            if (IterationElapsedTime &lt; MinTime) MinTime = IterationElapsedTime;
            if (IterationElapsedTime &gt; MaxTime) MaxTime = IterationElapsedTime;
        }
        ElapsedTime -= (MinTime + MaxTime);
        ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
        Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
    }
</code></pre>

<p>into somthing like this:</p>

<pre><code>MethotImLookingFor(AnySort(TestArray));
</code></pre>
