public class A
{
public void Afun(string msg)
{
Console.WriteLine("Class A : {0}", msg);
}
}
public class B : A
{
public void Bfun(string msg)
{
Console.WriteLine("Class B : {0}", msg);
}
}
static void
{
A objAB = new B();
objAB.Afun("objAB");
//objAB.Bfun(); Class A does not contain a definition for Bfun()
//B objBA = (B)new A();it's compile but not run
A objA = new A();
objA.Afun("objA");
B objB = new B();
objB.Afun("Inheritance");
objB.Bfun("Inheritance");
No comments:
Post a Comment