using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication4 ...{ class Program ...{ staticvoid Main(string[] args) ...{ A a =new C(); a.foo(); B b =new C(); b.foo(); Console.ReadKey(); } } class A ...{ publicvirtualvoid foo() ...{ Console.WriteLine("A"); } } class B : A ...{ newvirtualpublicvoid foo() ...{ Console.WriteLine("B"); } } class C : B ...{ overridepublicvoid foo() ...{ Console.WriteLine("C"); } } }
看代码 using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication4...{ class Program ...{ static void Main(string[] args) ...{ A a =