DecimalExtensions Class
Provides extension methods for the type decimal.
public static class DecimalExtensions
- Inheritance:
- object object
Methods
IsWithin(decimal, decimal, decimal)
Determines whether the two values are within a specified range.
public static bool IsWithin(this decimal left, decimal right, decimal difference)
| Parameter | Type | Description |
|---|---|---|
| left | decimal | The value on the left side of the comparison. |
| right | decimal | The value on the left side of the comparison. |
| difference | decimal | The difference threshold. |
Returns
- bool:
trueif the two values within a specified range; otherwise,false.
Range(decimal, decimal, decimal)
Returns the specified value constrained to the specified minimum and maximum values.
public static decimal Range(this decimal value, decimal minValue, decimal maxValue)
| Parameter | Type | Description |
|---|---|---|
| value | decimal | The value to constrain. |
| minValue | decimal | The minimum value. |
| maxValue | decimal | The maximum value. |
Returns
- decimal:
The specified value constrained to the specified minimum and maximum values.
Round(decimal, RoundMode)
Returns a rounded number using the specified RoundMode.
public static decimal Round(this decimal value, RoundMode mode)
| Parameter | Type | Description |
|---|---|---|
| value | decimal | The value to round. |
| mode | RoundMode | The RoundMode to use. |