Not sure when this was added but on the Enum class there is now a
Parse<TEnum>(stringValue)
Used like so with example in question:
var MyStatus = Enum.Parse<StatusEnum >("Active")
or ignoring casing by:
var MyStatus = Enum.Parse<StatusEnum >("active", true)
Here is the decompiled methods this uses:
[NullableContext(0)]
public static TEnum Parse<TEnum>([Nullable(1)] string value) where TEnum : struct
{
return Enum.Parse<TEnum>(value, false);
}
[NullableContext(0)]
public static TEnum Parse<TEnum>([Nullable(1)] string value, bool ignoreCase) where TEnum : struct
{
TEnum result;
Enum.TryParse<TEnum>(value, ignoreCase, true, out result);
return result;
}