Abstract Class
- Abstract class can contains abstract method and non-abstract method, and abstract method cannot be private. Meanwhile,
sealed
can not be declared withabstract
public abstract class Wheel { [error]abstract void Go(); public void Fix() { Console.WriteLine("This Wheel is Fixed"); } }
- class derives from abstract class have to implement all abstract method, if derived class is declared as abstract, then it can avoid implementing all the abstract methods
public class ConcreteWheel : Wheel { public override void Go() { throw new NotImplementedException(); } }
-
abstract class can inherit non-abstract class ```C# public abstract class Wheel: ConcreteWheel { abstract public void Go();
public void Fix() { Console.WriteLine(“This Wheel is Fixed”); } }
public class ConcreteWheel { } ```