Pergunta

I have a class which takes a generic class TState in its constructor, under the condition that TState can be converted to a UInt64using a TypeConverter. It will then be used as flags.

I want to use a [Flags] enum for TState, but even if I define it as

[Flags]  
public enum EState : ulong
{
    None = 0x0,
    State1= 0x1,
    State2= 0x2,
    State3= 0x4
}

then if TypeConverter typeConv = TypeDescriptor.GetConverter(typeof(EState)); typeConv.CanConvertTo(typeof(UInt64))is false.

How can I make an enum which will convert appropriately? Thanks!

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top