Let's look at the following procedure:
/// <summary>
/// 父类
/// 作者:周公
/// 首发地址:http://blog.csdn.net/zhoufoxcn/archive/2008/09/02/2864429.aspx
/// 日期:2008-09-01
/// </summary>
public class Father
{
public void Run0()
{
Console.WriteLine("Father.Run0");
}
}
/// <summary>
/// 子类
/// 作者:周公
/// 首发地址:http://blog.csdn.net/zhoufoxcn/archive/2008/09/02/2864429.aspx
/// 日期:2008-09-01
/// </summary>
public class Son:Father
{
public void Run0()
{
Console.WriteLine("Son.Run0");
}
}
class Program
{
static void Main(string[] args)
{
Father[] fatherList = new Father[2];
fatherList[0] = new Father();
fatherList[1] = new Son();
fatherList[0].Run0();
fatherList[1].Run0();
}
}
The results of the program's operation are:
Father.Run0
Father.Run0
A slightly attentive friend may find a brown wavy line under the Run0 method of the son class, and when we put the mouse over the underline, we see the following hint (this warning is also visible in the program's Output window when the program is compiled):
"MethodDemo.Son.Run0 ()" Hides the inherited member "MethodDemo.Father.Run0 ()". If you want to hide it intentionally, use the keyword new.
As shown in figure: