Created
July 8, 2019 12:33
-
-
Save noutram/ddf8f628308f0ad5d334359a482e7849 to your computer and use it in GitHub Desktop.
Method extension of an enumerated type in C#
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 Extensions | |
{ | |
public static string ToString(this BodyParameter p) | |
{ | |
switch (p) | |
{ | |
case BodyParameter.HEIGHT: | |
return "Height"; | |
case BodyParameter.WEIGHT: | |
return "Weight"; | |
default: | |
return ""; | |
} | |
} | |
}; | |
public enum BodyParameter | |
{ | |
HEIGHT = 0, | |
WEIGHT = 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment