界面输出
可见,此种做法是根据类型去调用方法,可以实现调用指定类层级的方法,而不用担心子类是否已重

(C#)
    class Program
    {
        static void Main(string[] args)
        {
            S3 s = new S3();
            // 调用S3.Methoed
            s.Method();


            // 调用S2.Methoed
            ((S2)s).Method();


            // 调用S1.Methoed
            ((S1)s).Method();


            Console.ReadLine();
        }
    }
    
      class S1
        {
            public virtual void Method()
            {
                Console.WriteLine("这是S1实例方法");
            }
        }
 
        class S2:S1
        {
            public new  void Method()
            {
                Console.WriteLine("这是S2实例方法");
            }
        }
 
        class S3 : S2
        {
            public new void Method()
            {
                Console.WriteLine("这是S3实例方法");
            }
        }
VB.net
Module Module1


    Sub Main()
        Dim s As New S3()
        s.Method()
        CType(s, S2).Method()
        CType(s, S1).Method()
        Console.ReadLine()
    End Sub


End Module




Class S1
    Public Overridable Sub Method()
        Console.WriteLine("这是S1实例方法")
    End Sub
End Class


Class S2
    Inherits S1


    Public Overloads Sub Method()
        Console.WriteLine("这是S2实例方法")
    End Sub
End Class


Class S3
    Inherits S2


    Public Overloads Sub Method()
        Console.WriteLine("这是S3实例方法")
    End Sub
End Class