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
- Boolean:
true
if 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. |