using System; namespace 抽象类与抽象方法 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); //B b = new B(); // B.Say(); C c = new C(); Console.WriteLine(c.add(1, 4)); Console.ReadKey(); } } abstract class B { public static void Say() { Console.WriteLine(); } public abstract int add(int a, int b); } class C:B { public override int add(int a,int b) { return a + b; } } }
抽象类就是为了实现继承;
抽象类不能实例化;
抽象类中的抽象方法不能用方法体;
继承于抽象类的非抽象派生类必须重写实现其基类的所有抽象方法;
原文:https://www.cnblogs.com/mlh1421/p/10806925.html