CSharp · Console
using System;
public class Program
{
public static void Main()
{
BaseClass s1 = new SecondChild();
s1.GetMethodOwnerName();
Console.WriteLine();
ChildClass s2 = new SecondChild();
s2.GetMethodOwnerName();
Console.WriteLine();
SecondChild s3 = new SecondChild();
s3.GetMethodOwnerName();
Console.WriteLine();
}
public class BaseClass
{
public virtual void GetMethodOwnerName()
{
Console.WriteLine("Base Class");
}
}
public class ChildClass : BaseClass
{
public new void GetMethodOwnerName()
{
base.GetMethodOwnerName();
Console.WriteLine("ChildClass");
}
}
public class SecondChild : ChildClass
{
public new void GetMethodOwnerName()
{
base.GetMethodOwnerName();
Console.WriteLine("Second level Child");
}
}
}