Hi,
According to your code I don't think it is possible. It is not possible because Visual Studio will give a compile error at b=a;. The reason is A is the parent class and the B is the child class. So compiler works according to the rule of 'No parent object can assigned to a child object". But vice-verse is possible. But you can overcome this compile error by casting as,
b = (B)a;
For this scenario this works because at the previous line you have assigned as
a = b
These classes are reference types, so after
a = b
'a' is actually a B class instance. If you remove the
a = b
then a run time exception will be throwed as
System.InvalidCastException
with the message
Unable to cast object of type 'A' to type 'B'
Regards.