Binary numbers

From Pigmeo - .NET/Mono/CLI (C#, VB.NET, C++/CLI, Nemerle...) for microcontrollers (PIC, dsPIC, AVR...)

using Pigmeo.Extensions;
 
byte foo;
foo = Convert.ToByte("00000111", 2); //Asign value 0x00000111 to foo
foo = "00000111".BinToByte(); //Asign value 0x00000111 to foo
foo.GetBit(5); //returns the value of bit 5
foo.SetBit(2, true); //sets bit 2 to "true"
 
UInt16 bar;
bar = "0001001010000001".BinToUInt16(); //Asign value 0x0001001010000001 to bar