singrdk/base/Windows/csic/test/override2.cs

24 lines
573 B
C#
Raw Normal View History

2008-11-17 18:29:00 -05:00
class A {
public virtual string Identity {
get { return "A.Identity(): " + ToString(); }
}
public void print() { System.Console.WriteLine(Identity); }
}
class B: A {
override public string ToString() { return "B.ToString()"; }
override public string Identity {
get { return "B.Identity(): " + base.ToString(); }
}
}
class test {
public static void Main() {
A a = new A();
a.print();
B b = new B();
b.print();
System.Console.WriteLine("{0}", ((A)b).Identity);
System.Console.WriteLine("{0}", b.Identity);
((A)b).print();
}
}