Class ComparableExtension
- Namespace
- Loehnert.Utility.Extensions
- Assembly
- Loehnert.Utility.dll
Extensions for objects of type IComparable.
public static class ComparableExtension
- Inheritance
-
ComparableExtension
- Inherited Members
Methods
Clamp<T>(T, T, T)
Clamps value
, between min
and max
.
public static T Clamp<T>(this T value, T min, T max) where T : IComparable
Parameters
value
TValue to clamp.
min
TThe minimum value.
max
TThe maximum value.
Returns
- T
Clamped value.
Type Parameters
T
A IComparable object type.
Remarks
Returns the min or max value if value is smaller or bigger, otherwise the value will be returned.
IsInLimits<T>(T, T, T)
Returns a a value indicating whether the value
is in limits.
public static bool IsInLimits<T>(this T value, T min, T max) where T : IComparable
Parameters
value
TValue to compare.
min
TThe minimum value.
max
TThe maximum value.
Returns
- bool
true if value is greater or equal than min and value is less or equal than max.
Type Parameters
T
The IComparable type.