title: Difference between instantiating using base class and derived class
body: <p>Can someone explain me the difference between instantiating a derived class by referring through the base class and instantiating a derived class by the derived class name itself.</p>
  
  <p>Please go through this program</p>
  
  <pre><code>    using System;
  
      abstract class Test
      {
          public int _a;
          public abstract void A();
      }
  
      class Example1 : Test
      {
          public override void A()
          {
          Console.WriteLine("Example1.A");
          base._a++;
          }
      }
  
      class Example2 : Test
      {
          public override void A()
          {
          Console.WriteLine("Example2.A");
                  base._a--;
          }
      }
  
      class Program
      {
          static void Main()
          {
          // Reference Example1 through Test type.
          Test test1 = new Example1();
          test1.A();
  
          Example2 test2 = new Example2();
          test2.A();
          }
      }
  </code></pre>
  
  <p>Here is the question again, inside the Main() method two objects are created. </p>
  
  <p>First object test1 is referenced through Test(base class) type, what does it actually mean ? and what difference does it make comapred to the second object which is based on the derived class ?</p>
  
  <p>In a program which is preferred, referencing the base class or the derived class, how does it help ?</p>
  
  <p>I know my question is a little vague but any idea on this would be very helpful for me to learn further. Thanks in advance.</p>