Class Comparison
Provides generic methods to work with comparable values.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Comparison
Methods
| Improve this Doc View SourceAsValueFunc<T>(Comparison<T>, Boolean)
Converts comparison method into ValueFunc<T1, T2, TResult>.
Declaration
public static ValueFunc<T, T, int> AsValueFunc<T>(this Comparison<T> comparison, bool wrap = false)
Parameters
Type | Name | Description |
---|---|---|
Comparison<T> | comparison | The delegate representing comparison method. |
Boolean | wrap | true to wrap |
Returns
Type | Description |
---|---|
ValueFunc<T, T, Int32> | The value delegate represeting comparison method. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to compare. |
Between<T>(T, T, T, BoundType)
Checks whether specified value is in range.
Declaration
public static bool Between<T>(this T value, T left, T right, BoundType boundType = BoundType.Open)
where T : IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to check. |
T | left | Range left bound. |
T | right | Range right bound. |
BoundType | boundType | Range endpoints bound type. |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
T | Type of value to check. |
Clamp<T>(T, T, T)
Restricts a value
in specific range.
Declaration
public static T Clamp<T>(this T value, T min, T max)
where T : IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to be restricted. |
T | min | Minimal range value. |
T | max | Maximum range value. |
Returns
Type | Description |
---|---|
T |
|
Type Parameters
Name | Description |
---|---|
T | Type of the values. |