title: Why do we assign child class object to parent class reference variable?
body: <p>I have the following code.</p>
  
  <pre><code>public class Parent
  {
      public void Print()
      {
          Console.WriteLine ("Parent Method");
      }
  }
  
  public class Child : Parent
  {
      public new void Print()
      {
          Console.WriteLine ("Child Method");
      }
  }
  
  public class Program
  {
      public static void Main()
      {
          Child C = new Child();
          C.Print();
      }
  }
  </code></pre>
  
  <p>If I run this code, I get the result "Child Method"
  But if I do the following, why do I get the result "Parent Method"?</p>
  
  <pre><code>public class Parent
  {
      public void Print()
      {
          Console.WriteLine ("Parent Method");
      }
  }
  
  public class Child : Parent
  {
      public new void Print()
      {
          Console.WriteLine ("Child Method");
      }
  }
  
  public class Program
  {
      public static void Main()
      {
          Parent P = new Child();   // The only difference is this.
          P.Print();
      }
  }
  </code></pre>
  
  <p>The only difference is as below</p>
  
  <pre><code>Child C = new Child();   
  Parent P = new Child();
  </code></pre>
  
  <p>I thought <code>new Child()</code> means that we create the instance of <code>Child</code> class. 
  And I thought both, <code>C</code> and <code>P</code>, are just object reference variables that hold the location of instance of <code>Child</code> class.<br>
  Can you correct me if I'm wrong or tell me if I miss something because I don't understand why in the above cases I get different results?</p>