diff --git a/X10D/src/ComparableExtensions/ComparableExtensions.cs b/X10D/src/ComparableExtensions/ComparableExtensions.cs index bc9cf14..62b40ec 100644 --- a/X10D/src/ComparableExtensions/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions/ComparableExtensions.cs @@ -162,5 +162,59 @@ namespace X10D.ComparableExtensions { return value.CompareTo(other) <= 0; } + + /// + /// Returns the maximum of two values. + /// + /// The first value. + /// The second value. + /// A type which implements . + /// G + /// if is greater than + /// -or- + /// otherwise. + /// + /// + /// + /// int first = 5; + /// int second = 10; + /// + /// int max = first.Max(second); + /// // max will be 10 + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static T Max(this T value, T other) + where T : IComparable + { + return value.GreaterThan(other) ? value : other; + } + + /// + /// Returns the minimum of two values. + /// + /// The first value. + /// The second value. + /// A type which implements . + /// + /// if is less than + /// -or- + /// otherwise. + /// + /// + /// + /// int first = 5; + /// int second = 10; + /// + /// int min = first.Min(second); + /// // min will be 5 + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static T Min(this T value, T other) + where T : IComparable + { + return value.LessThan(other) ? value : other; + } } }