title: derived class cannot display value of base class variables in C#
body: <p>I am trying to execute the following code</p>
  
  <pre><code>class A
  {
      protected int a;
      protected char b;
      public void Show()
      {
          a=5;
          MessageBox.Show(""+a);
      }
  }
  
  class B:A
  {
      public void Show()
      {
          b='z';
          MessageBox.Show(""+a+ ""+b);
      }
  }
  </code></pre>
  
  <p>I am getting <code>5</code> (value of <code>a</code>) as the output when I do <code>aa.show()</code> where <code>aa</code> is the instance of <code>A</code> but when I do <code>bb.show()</code>, where <code>bb</code> is the instance of <code>B</code>, the output comes out as <code>0</code> (value of <code>a</code>) <code>z</code> (value of <code>b</code>).</p>
  
  <p>Can someone please explain why the derived class is unable to display the current value of a even though it has been declared as protected whereas it is able to display the correct value of <code>b</code>?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I'll try the solutions suggested. Regarding the compilation error, there was none and I was able to get the output as mentioned in the question. </p>