Skip to content

Instantly share code, notes, and snippets.

@dannylloyd
Created September 18, 2018 13:19
Show Gist options
  • Select an option

  • Save dannylloyd/10432457172640187acf045f977c3d94 to your computer and use it in GitHub Desktop.

Select an option

Save dannylloyd/10432457172640187acf045f977c3d94 to your computer and use it in GitHub Desktop.
How to parse an enum
//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