Created
September 18, 2018 13:19
-
-
Save dannylloyd/10432457172640187acf045f977c3d94 to your computer and use it in GitHub Desktop.
How to parse an enum
This file contains hidden or 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
| //From String | |
| var result = (EnumNameHere)Enum.Parse(typeof(EnumNameHere), stringValue); | |
| //From Integer | |
| var result = (EnumNameHere)integerValue; | |
| //To Integer | |
| var result = (int)enumValue; | |
| //To String | |
| var result = enumValue.ToString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment