A byte is an 8-bit unsigned integer. The ToByte
method of the Convert class converts other base data types to a byte data type.
Convert a Boolean to a Byte
-
- Console.WriteLine("Convert boolean type to Byte");
- bool f = false;
- bool t = true;
- byte bf = Convert.ToByte(f);
- byte bt = Convert.ToByte(t);
- Console.WriteLine("{0} converted to {1}.", f, bf);
- Console.WriteLine("{0} converted to {1}.", t, bt);