Use bitwise AND to determine if a number is odd. : Bitwise AND « Data Type « C# / CSharp Tutorial






using System; 
 
class Example {  
  public static void Main() { 
    ushort num;  
 
    num = 10; 
 
    if((num & 1) == 1) 
      Console.WriteLine("This won't display."); 
 
    num = 11; 
 
    if((num & 1) == 1) 
      Console.WriteLine(num + " is odd."); 
 
  } 
}
11 is odd.








2.43.Bitwise AND
2.43.1.bitwise AND
2.43.2.Use bitwise AND to make a number even
2.43.3.Use bitwise AND to determine if a number is odd.