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
valueTValue to clamp.
minTThe minimum value.
maxTThe maximum value.
Returns
- T
Clamped value.
Type Parameters
TA 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
valueTValue to compare.
minTThe minimum value.
maxTThe maximum value.
Returns
- bool
true if value is greater or equal than min and value is less or equal than max.
Type Parameters
TThe IComparable type.