I am trying to execute the following 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);
}
}
i am getting 5 (value of a) as the output when i do aa.show () where aa is the instance of A but when i do bb.show() ,where bb is the instance of B, the output comes as 0 (value of a) z (value of b) 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 b?