Display the bits within a byte. : Bits « Data Type « C# / CSharp Tutorial






using System; 
 
class Example { 
  public static void Main() { 
    int t; 
    byte val;  
  
    val = 123; 
    for(t=128; t > 0; t = t/2) { 
      if((val & t) != 0) 
         Console.Write("1 ");  
      if((val & t) == 0) 
         Console.Write("0 ");  
    } 
  } 
}
0 1 1 1 1 0 1 1








2.42.Bits
2.42.1.Bitwise Operators
2.42.2.Display the bits within a byte.
2.42.3.Use enum value to mark BitArrays
2.42.4.Converts the bit patterns of UInt32 values to Byte arrays with the GetBytes method.