It sounds like what you are looking for is Bitwise Operations. By defining your enum to have only one bit set for each of the values, you can perform several interesting operations, including the one I think you are asking about. To define an enum to use like this you might use something like the following:
[Flags]
enum myEnum :int
{
None = 0,
field1 = (1 << 0), //1 binary: 001
field2 = (1 << 1), //2 010
field3 = (1 << 2), //4 100
anyfield = (1 << 3) -1, // 111
field1or2 = (field1 | field2),// 011
field1or3 = (field1 | field3),// 101
field2or3 = (field2 | field3), 110
}
The syntax for initializing the values of the enum are there to make it easy to look at the list and see that exactly one bit is set and all powers of two are used. To check for multiple values you can use:
//set to field2or3
myEnum myvar = myEnum.field2or3;
//add in field1
myvar |= myEnum.field1;
//clear field2
myvar &= myEnum.field2;
//true because field1 is set, even though field2 is not
if ((myvar & myEnum.field1or2) != myEnum.None)
{
//...
}
or
if((myvar & (int)myEnum.field1or2) != 0)
if myvar is an int (C# requires an explicit cast to int, unlike C++). Bitwise operations are a little tricky at first, but with a bit of practice you should be able to figure it out.