GeekInterview.com
Series: Subject: Topic:
Question: 9 of 460

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));

Asked by: annadm | Member Since Jun-2011 | Asked on: Jun 14th, 2011

View all questions by annadm

This Question is not yet answered!

Related Open Questions

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.