
Hi
1. The object is of derived class as you have written
new DerivedClass();
you can call the
baseClass.GetType()
method to see it.
This object has been type casted to that of a base class which will restrict the use to member/method of base class only.
lets say i have two classes as follows
public class MyBaseClass
{
public int BaseID { get; set; }
}
public class DerivedClass:MyBaseClass
{
public int DerivedID { get; set; }
}
and i am writing something like
MyBaseClass b = new DerivedClass { BaseID = 10, DerivedID = 20 };
Console.WriteLine(b.BaseID);
here i will only get BaseID, I can again typecast the same object to get DerivedID
DerivedClass d = b as DerivedClass;
Console.WriteLine(d.DerivedID);
Thanks,
Debata
Akiii, if this helps please login to Mark As Answer. | Alert Moderator