海绵宝宝撒
using System; namespace ConsoleApp{ public class A { public virtual int MyFunction(int value) { return value + 10; } } public class B : A { public override int MyFunction(int value) { int v = base.MyFunction(value) return v + 50; } } class Program { static void Main(string[] args) { A a = new A(); int v1 = a.MyFunction(100); Console.WriteLine("A.MyFunction(100) = {0}", v1); B b = new B(); int v2 = b.MyFunction(100); Console.WriteLine("B.MyFunction(100) = {0}", v2); Console.ReadKey(); } }}