title: C# creating an instance of a class and derived class
body: <p>I tried the below code in my c# program. This is just for learning the OOPs Concepts.</p>
  
  <pre><code> class a
      {      
          public void testa()
          {
          }
      }
      class b:a
      {     
          public void testb()
          {
          }
      }
  
    a a1 = new b();
  
    b b1 = new a();
  </code></pre>
  
  <p>I have the following queries regarding the code mentioned above.</p>
  
  <ol>
  <li>Why Im getting error in 2nd line?</li>
  <li>what is meant by <code>a a1=new b()</code>;</li>
  <li>why <code>a1.testb()</code> is not accessible even though constructor of <code>b</code> is assigned to <code>a1</code>?</li>
  <li>what is the difference between  <code>a a1=new a()</code> and <code>a a1=new b()</code>?</li>
  </ol>