Ok, in that case, it will work. However, this is not the common case,
but you are right. The only drawback to this is that you limit yourself to
the number of values that you can contain in your enumeration which can be
effective bit mappings (the max you can have is 32 right now).
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
100 said:
Hi, it
work
What do you mean?
I may have flag that uses more then one bit.
for example one flag occupies the first two less significant bits (0 and
1st) (flag1 = 0x3)
then one flag that uses 3th and 5th bit let say (flag2 = 0x14).
enum MyFlags
{
Flag1 = 0x3,
Flag2 = 0x14
}
MyFlags flags = MyFlags.Flag1 | MyFlags.Flag2;
Do you want to say that this is incorrect or this won't work correctly?
Yes, I agree that usually one flag uses only one bit, but not always. There
is nothing wrong to have one flag represented by more then one bit. It will
work correctly as long as the semantic of those flags is correct.
B\rgds
100