ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsOdd

Checks whether a number is odd

Source

public static bool IsOdd(this int value)
{
    return value % 2 != 0;
}

Example

int number = 1;
bool isOdd = number.IsOdd(); // true

int number = 2;
bool isOdd = number.IsOdd(); // false

Author: K M Thomas

Submitted on: 25 mrt. 2016

Language: C#

Type: System.Int32

Views: 8040