ソースコード
public static class IntExtensions { /// <summary> /// 偶数かどうかを返します /// </summary> public static bool IsEven( this int self ) { return self % 2 == 0; } }
使い方
int n1 = 1; int n2 = 2; n1.IsEven(); // False n2.IsEven(); // True
public static class IntExtensions { /// <summary> /// 偶数かどうかを返します /// </summary> public static bool IsEven( this int self ) { return self % 2 == 0; } }
int n1 = 1; int n2 = 2; n1.IsEven(); // False n2.IsEven(); // True