Int16 - IsEven

An Int16 extension method that query if '@this' is even.

Try it

public static void Main()
{
    Int16 [] values = { 1, 7, 30, 365, 1000, 2500, 10000, 15000, 32767 };

    Console.WriteLine("{0,21}{1,18}","Value", "Is Even");
    Console.WriteLine("{0,21}{1,18}","-----", "-------");

    foreach (Int16 value in values)
    {
		// C# Extension Method: Int16 - IsEven
        Console.WriteLine("{0,21}{1,18}", value, value.IsEven() ? "True": "False");
    }
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     An Int16 extension method that query if '@this' is even.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>true if even, false if not.</returns>
    public static bool IsEven(this Int16 @this)
    {
        return @this%2 == 0;
    }
}