.NET Extensions to simplify work with bits
byte b = 0x0F;
b = b.SetBit(4); //Base is Zero
//b == 0b00011111
b = b.ClearBit(1); //Base is Zero
//b == 0b00011101
b = b.ToggleBit(1); //Base is Zero
//b == 0b00011111
b = b.ToggleBit(1); //Base is Zero
//b == 0b00011101
b = b.ChangeBit(0, true); //Base is Zero
b = b.ChangeBit(1, true); //Base is Zero
//b == 0b00011111
bool flag = b.IsBitSet(1);
//flag == true