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

IsEven

Checks whether a number is even

Source

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

Example

int number = 1;
bool isEven = number.IsEven(); // false

int number = 2;
bool isEven = number.IsEven(); // true

Author: K M Thomas

Submitted on: 25 mrt. 2016

Language: C#

Type: System.Int32

Views: 8021