class DerivedClass : BaseClass
{
public string _className = "DerivedClass";
public override void PrintName()
{
Console.Write("The BaseClass Name is {0}");
//调用父类方法
base.PrintName();
Console.WriteLine("This DerivedClass is {0}", this._className);
}
}
class test1
{
public static void Main()
{
DerivedClass dc = new DerivedClass();
dc.PrintName();
Console.ReadKey();
}
}
BaseClass = 父类 , DerivedClass = 子类