Use C# to turn on the 4th and 7th bits

Use C# to turn on the 4th and 7th bits of a said byte myFlag, in which right most bit is first bit.

Answer

[Flags]
enum BitFlags : byte
{
One = (1 << 0),
Two = (1 << 1),
Three = (1 << 2),
Four = (1 << 3),
Five = (1 << 4),
Six = (1 << 5),
Seven = (1 << 6),
Eight = (1 << 7)
}
BitFlags myFlag = BitFlags.Four | BitFlags.Seven;

Console.WriteLine(Convert.ToString((byte)myFlag, 2));

Questions by annadm

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions