Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Created May 19, 2020 21:42
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/51edfe548ae885d274a9a182315ab182 to your computer and use it in GitHub Desktop.
Save ankitvijay/51edfe548ae885d274a9a182315ab182 to your computer and use it in GitHub Desktop.
Enumeration Classes - Part 1 (PaymentType Enum - PaymentTypeExtensions)
public static class PaymentTypeExtensions
{
public static string GetPaymentTypeCode(this PaymentType paymentType)
{
switch (paymentType)
{
case PaymentType.CreditCard:
return "CC";
case PaymentType.DebitCard:
return "DC";
default:
throw new ArgumentOutOfRangeException(
nameof(paymentType), paymentType, "Invalid payment type");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment