Created
May 19, 2020 21:42
-
-
Save ankitvijay/51edfe548ae885d274a9a182315ab182 to your computer and use it in GitHub Desktop.
Enumeration Classes - Part 1 (PaymentType Enum - PaymentTypeExtensions)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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