How do I  

Convert a Boolean to a Byte in C#

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

  1. // Convert a boolean type to a Byte  
  2. Console.WriteLine("Convert boolean type to Byte");  
  3. bool f = false;  
  4. bool t = true;  
  5. byte bf = Convert.ToByte(f);  
  6. byte bt = Convert.ToByte(t);  
  7. Console.WriteLine("{0} converted to {1}.", f, bf);  
  8. Console.WriteLine("{0} converted to {1}.", t, bt); 

Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.