using System;
public class A {
public virtual void Display () {
Console.WriteLine("运行时类型:" + this.GetType().ToString());
Console.WriteLine("这是A类的成员函数BaseDisplay().");
}
public virtual void Display (string content) {
Console.WriteLine("运行时类型:" + this.GetType().ToString());
Console.WriteLine("这是A类的成员函数BaseDisplay()的重载.字符串内容为:" + content);
}
}
public class B : A {
public override void Display () {
Console.WriteLine("运行时类型:" + this.GetType().ToString());
Console.WriteLine("这是B类的成员函数Display().");
}
public override void Display (string content) {
Console.WriteLine("运行时类型:" + this.GetType().ToString());
Console.WriteLine("这是B类的成员函数Display()的重载.字符串内容为:" + content);
}
public static void Main (string [] args) {
A a = new A();
B b = new B();
a.Display();
a.Display("My Name Is a.");
b.Display();
b.Display("My Name Is b.");
A newA = b;
newA.Display();
}
}
如此简单的问题还要问啊?
这个我有,明天发上来