Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Created August 7, 2020 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitvijay/a3e87ba586a7a6d588f38e11f4b6ff2d to your computer and use it in GitHub Desktop.
Save ankitvijay/a3e87ba586a7a6d588f38e11f4b6ff2d to your computer and use it in GitHub Desktop.
Part 5 - Inheritance Example 2 - PaymentType.cs
public abstract class PaymentType : Enumeration
{
public static readonly PaymentType DebitCard = new DebitCardType();
public static readonly PaymentType CreditCard = new CreditCardType();
public abstract string Code { get; }
protected PaymentType(int value, string name = null) : base(value, name)
{
}
protected class DebitCardType : PaymentType
{
public DebitCardType() : base(0, "DebitCard")
{
}
public override string Code => "DC";
}
protected class CreditCardType : PaymentType
{
public CreditCardType() : base(1, "CreditCard")
{
}
public override string Code => "CC";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment