CSharp/C# Tutorial - C# Abstract Classes

An abstract class is a special class to represent a abstract concept. For example, Integer is a concrete while Number is abstract. Shape is abstract while Circle is concrete.

A class declared as abstract can never be instantiated.

Only its concrete subclasses can be instantiated.

Abstract classes are able to define abstract members.


That implementation must be provided by the subclass, unless that subclass is also declared abstract:

public abstract class Item { 
    // Note empty implementation 
    public abstract decimal NetValue { get; } 
} //from   w ww  .  j ava  2  s .  com

public class Product : Item { 
    public long InStoreCount; 
    public decimal CurrentPrice;
    // Override like a virtual method. 
    public override decimal NetValue {
       get { 
          return CurrentPrice * InStoreCount;