Answers for "get enum from variable"

C#
2

get enum int by name

int enumInt = (int) Enum.Parse(typeof(Your_Enum), string_name);
Posted by: Guest on February-12-2021
0

Get Enum Name

//Option 1:
string m = Enum.GetName(typeof(MyEnumClass), value);
//Option 2:
string n = nameof(MyEnumClass.Value);
Posted by: Guest on June-07-2021

C# Answers by Framework

Browse Popular Code Answers by Language