internal static class EnumUtils public static bool TryParse TEnum stri

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
internal static class EnumUtils
{
public static bool TryParse<TEnum>(string text, out TEnum value)
{
if (!Enum.IsDefined(typeof(TEnum), text))
{
value = default(TEnum);
return false;
}
value = (TEnum)Enum.Parse(typeof(TEnum), text);
return true;
}
}