I have the following listing
public enum MaritalStatus
{
Married = 'M',
Widow = 'W',
Widower = 'R',
Single='S'
}
In one function, I have for exp: 'S'and I need to have MaritalStatus.Single.
How can I get an enumeration from a character value ? for the string, I found this solution, but it gets an exception for Char.
YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString);
Any help?
source
share