How to use less code for this situation
<p>Currently, I have code like this:</p>

<pre><code>    static void Main()
    {
        int whichClass = 0;
        if (whichClass == 0)
        {
            //repeat code
            TestAbstract clTest = new ClassA();
            clTest.MainFunc();
        }
        else if (whichClass == 1)
        {
            //repeat code
            TestAbstract clTest = new ClassB();
            clTest.MainFunc();
        }
        else if (whichClass == 10)
        {
            //repeat code
            TestAbstract clTest = new ClassX();
            clTest.MainFunc();
        }
    }
</code></pre>

<p>As you see, I have to write code 3 times for initial and call function at 3 different classes. </p>

<p>What I want is we just call 1 time with dynamic class. How can it is possible?</p>
