Int64 - IsOdd
An Int64 extension method that query if '@this' is odd.
public static void Main() { Int64 [] values = { 1, 7, 30, 365, 1000, 2500, 10000, 15000, 32767 }; Console.WriteLine("{0,21}{1,18}","Value", "Is Odd"); Console.WriteLine("{0,21}{1,18}","-----", "-------"); foreach (Int64 value in values) { // C# Extension Method: Int64 - IsOdd Console.WriteLine("{0,21}{1,18}", value, value.IsOdd() ? "True": "False"); } }
View Source
using System; public static partial class Extensions { /// <summary> /// An Int64 extension method that query if '@this' is odd. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>true if odd, false if not.</returns> public static bool IsOdd(this Int64 @this) { return @this%2 != 0; } }