public Sample matchStringToSample(string match)
{
return (Sample)Enum.Parse(typeof(Sample), match);
}
You will have to handle the case where a string match is not a valid enumeration value. Enum.Parsethrows out ArgumentExceptionin this case.
source
share