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