Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Last active May 29, 2020 02:16
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/bcc918e47fa82a3610aeef2e5df687fa to your computer and use it in GitHub Desktop.
Save ankitvijay/bcc918e47fa82a3610aeef2e5df687fa to your computer and use it in GitHub Desktop.
Enumeration Classes - Part 1 - PaymentType Enumeration with Behavior
public abstract class PaymentType : Enumeration
{
public static readonly PaymentType DebitCard = new DebitCardType();
public static readonly PaymentType CreditCard = new CreditCardType();
public abstract string Code { get; }
private PaymentType(int value, string name = null) : base(value, name)
{
}
private class DebitCardType : PaymentType
{
public DebitCardType() : base(0, "DebitCard")
{
}
public override string Code => "DC";
}
private 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