class A
{
public virtual void Print()
{
Console.WriteLine("We are in Class A.");
}
}
class C : A
{
public new void Print()
{
Console.WriteLine("We are in Class C.");
}
}
class Program
{
static void Main(string[] args)
{
A a = new A();
a.Print();
Console.ReadKey();
C c = new C();
c.Print();
Console.ReadKey();
A aa = new C();
aa.Print();
Console.ReadKey();
A aaa = (A)c;
aaa.Print();
Console.ReadKey();
//C ccc = (C)a;
//ccc.Print();
//Console.ReadKey();
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment