diff --git a/X10D/src/ComparableExtensions/ComparableExtensions.cs b/X10D/src/ComparableExtensions/ComparableExtensions.cs index d357e9d..bc9cf14 100644 --- a/X10D/src/ComparableExtensions/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions/ComparableExtensions.cs @@ -50,5 +50,117 @@ namespace X10D.ComparableExtensions { return actual.CompareTo(lower) > 0 && actual.CompareTo(upper) < 0; } + + /// + /// Determines if the current value is greater than another value. + /// + /// The first value. + /// The second value. + /// An type. + /// The comparison operand type. + /// + /// if is greater than + /// -or- + /// otherwise. + /// + /// + /// + /// int first = 5; + /// int second = 10; + /// + /// bool result = first.GreaterThan(second); + /// // result will be False + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool GreaterThan(this T1 value, T2 other) + where T1 : IComparable + { + return value.CompareTo(other) > 0; + } + + /// + /// Determines if the current value is greater than or equal to another value. + /// + /// The first value. + /// The second value. + /// An type. + /// The comparison operand type. + /// + /// if is greater than or equal to + /// -or- + /// otherwise. + /// + /// + /// + /// int first = 5; + /// int second = 10; + /// + /// bool result = first.GreaterThanOrEqualTo(second); + /// // result will be False + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool GreaterThanOrEqualTo(this T1 value, T2 other) + where T1 : IComparable + { + return value.CompareTo(other) >= 0; + } + + /// + /// Determines if the current value is less than another value. + /// + /// The first value. + /// The second value. + /// An type. + /// The comparison operand type. + /// + /// if is less than + /// -or- + /// otherwise. + /// + /// + /// + /// int first = 5; + /// int second = 10; + /// + /// bool result = first.LessThan(second); + /// // result will be True + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool LessThan(this T1 value, T2 other) + where T1 : IComparable + { + return value.CompareTo(other) < 0; + } + + /// + /// Determines if the current value is less than or equal to another value. + /// + /// The first value. + /// The second value. + /// An type. + /// The comparison operand type. + /// + /// if is less than or equal to + /// -or- + /// otherwise. + /// + /// + /// + /// int first = 5; + /// int second = 10; + /// + /// bool result = first.LessThanOrEqualTo(second); + /// // result will be True + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool LessThanOrEqualTo(this T1 value, T2 other) + where T1 : IComparable + { + return value.CompareTo(other) <= 0; + } } }