Enumeration sets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please tell me there is an option for sets of enumeration in c# !?

eg : enum DataKind {dkSimple, dkComplex, dkCool
<DataKindSet> = Set of DataKind //Delphi style thoug

DataKindSet VariableofDataKindSet = new DataKindSet(dkSimple, dkCool)

No ?
Alternatives please

-Niti
 
Cheers Chris...looks interesting

I was thinking on using bit fields directly..
enum DataKind {dkSimple = 1, dkComplex = 2, dkCool = 4}

then do bitwise operations to manipulate the set, wherein the set itself could be just integer variables
int aSet = ((int)DataKind .dkSimple | (int)DataKind .dkCool ....et

-Nitin
 
Cheers Chris...looks interesting.

I was thinking on using bit fields directly...
enum DataKind {dkSimple = 1, dkComplex = 2, dkCool = 4},

then do bitwise operations to manipulate the set, wherein the
set itself could be just integer variables int aSet =
((int)DataKind .dkSimple | (int)DataKind .dkCool ....etc

-Nitin

Yes, that can be done by using the FlagsAttribute:

[Flags]
enum DataKind {dkSimple = 1, dkComplex = 2, dkCool = 4};

int aSet = (int) (DataKind.dkSimple | DataKind.dkComplex);
 
Back
Top