DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="0.11.0" />

 Comparable

public static class Comparable
Provides generic methods to work with comparable values.
public static bool Between<T>(this T value, T left, T right, BoundType boundType = 0) where T : IComparable<T>

Checks whether specified value is in range.

public static T Clamp<T>(this T value, T min, T max) where T : IComparable<T>

Restricts a value in specific range.

public static T Max<T>(T first, T second, Comparison<T> comparer)

Returns the larger of two values.

public static T Max<T>(T first, T second, IComparer<T> comparer)

Returns the larger of two values.

public static T Max<T>(this T first, T second) where T : IComparable<T>

Returns the larger of two values.

public static T Min<T>(T first, T second, Comparison<T> comparer)

Returns the smaller of two values.

public static T Min<T>(T first, T second, IComparer<T> comparer)

Returns the smaller of two values.

public static T Min<T>(this T first, T second) where T : IComparable<T>

Returns the smaller of two values.