Method
Parse
Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object.
public enum Color
{
[Description("#4CAF50")]
Success=1,
[Description("#dc3545")]
Danger=2,
[Description("#007bff")]
Primary=3,
[Description("#ffc107")]
Warning=4,
[Description("#17a2b8")]
Info=5
}
"Primary".Parse<Color>()
"1".Parse<Color>()
output:
Primary
Success
GetDescription
Get assembly attribute
Color.Danger.GetDescription()
output:
#dc3545