Returns true
if the given number is even, false
otherwise.
Check whether a number is odd or even using the modulo (%
) operator.
Return true
if the number is even, false
if the number is odd.
代码实现
public static partial class _30s
{
public static bool IsEven(int n)
{
return n % 2 == 0;
}
}
使用样例
_30s.IsEven(2); // true
_30s.IsEven(3); // false