using System;
public class Program
{
public static void Main()
new A().MyMethod();
new B().MyMethod();
new C().MyMethod();
Console.WriteLine("\nWhich gets called when casted to type A?");
((A)new B()).MyMethod();
((A)new C()).MyMethod();
}
public class A
public void MyMethod()
Console.WriteLine("Defined in class A");
public class B : A
Console.WriteLine("Defined in class B");
public class C : A
public new void MyMethod()
Console.WriteLine("Defined in class C");