Код: Выделить всё
public abstract class EnumType
where TEnum : struct, IConvertible
where TValue : struct
{
public abstract TEnum GetEnumValue(TValue value);
}
Код: Выделить всё
public sealed class ByteEnumType : EnumType
where T : struct, IConvertible
{
public override T GetEnumValue(byte value) => (T)Enum.ToObject(typeof(T), (int)value);
}
Код: Выделить всё
public sealed class CharEnumType : EnumType
where T : struct, IConvertible
{
public override T GetEnumValue(char value) => (T)Enum.ToObject(typeof(T), (int)value);
}
Можно ли как-нибудь избежать этой упаковки?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -enum-type