Find out whether the provided 64 bit integer is an even number. - CSharp System

CSharp examples for System:Math Number

Description

Find out whether the provided 64 bit integer is an even number.

Demo Code

// Crystal AI is free software: you can redistribute it and/or modify
using System;//from  www .j  a  v a  2 s  .c om

public class Main{
        /// <summary>
    ///   Find out whether the provided 64 bit integer is an even number.
    /// </summary>
    /// <param name="number">The number to very whether it's even.</param>
    /// <returns>True if and only if it is an even number.</returns>
    public static bool IsEven(this long number) {
      return (number & 0x1) == 0x0;
    }
        /// <summary>
    ///   Find out whether the provided 32 bit integer is an even number.
    /// </summary>
    /// <param name="number">The number to very whether it's even.</param>
    /// <returns>True if and only if it is an even number.</returns>
    public static bool IsEven(this int number) {
      return (number & 0x1) == 0x0;
    }
}

Related Tutorials