Preview:
using System;

​

public class Program

{

    public static void Main(String[] args)

    {    

        Console.WriteLine( NumberUtils.IsOdd(0) );   // false

        Console.WriteLine( NumberUtils.IsOdd(1) );   // true      // odd

        Console.WriteLine( NumberUtils.IsOdd(2) );   // false

        Console.WriteLine( NumberUtils.IsOdd(3) );   // true      // odd

        Console.WriteLine( NumberUtils.IsOdd(4) );   // false

        Console.WriteLine( NumberUtils.IsOdd(5) );   // true      // odd

​

        Console.WriteLine( NumberUtils.IsOdd(-1) );  // true      // odd

        Console.WriteLine( NumberUtils.IsOdd(-2) );  // false

        Console.WriteLine( NumberUtils.IsOdd(-3) );  // true      // odd

        Console.WriteLine( NumberUtils.IsOdd(-4) );  // false

        Console.WriteLine( NumberUtils.IsOdd(-5) );  // true      // odd

    }

}

​

public class NumberUtils

{

    public static bool IsOdd(int number)

    {

        return (number & 1) != 0;

    }

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter