I would like to do this but it does not work.
bool TryGetEnum<TEnum, TValue>(TValue value, out TEnum myEnum)
{
value = default(TEnum);
if (Enum.IsDefined(typeof(TEnum), value))
{
myEnum = (TEnum)value;
return true;
}
return false;
}
Example usage:
MyEnum mye;
bool success = this.TryGetEnum<MyEnum,char>('c',out mye);