Abstract Classes and Abstract Members - CSharp Custom Type

CSharp examples for Custom Type:abstract

Introduction

A abstract class can never be instantiated.

Abstract classes can define abstract members.

Abstract members are like virtual members without a default implementation.

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

public abstract class Item
{
  public abstract decimal NetValue { get; }
}

public class Stock : Item
{
  public long SharesOwned;
  public decimal CurrentPrice;

  // Override like a virtual method.
  public override decimal NetValue => CurrentPrice * SharesOwned;
}

Related Tutorials