public static EstimaatorMethods StringToEnumMethods(string enumVal) { EstimaatorMethods enumResult = new EstimaatorMethods(); try { enumResult = (EstimaatorMethods)Enum.Parse(typeof(EstimaatorMethods), enumVal); } catch (ArgumentException ex) { // Not Handled } return(enumResult); }
public static string EnumToString(this EstimaatorMethods val) { DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }