DecimalExtensions Class
Provides extension methods for the type System.Decimal.
public static class DecimalExtensions
- Inheritance:
- System.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 | System.Decimal | The value on the left side of the comparison. |
right | System.Decimal | The value on the left side of the comparison. |
difference | System.Decimal | The difference threshold. |
Returns
- System.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 | System.Decimal | The value to constrain. |
minValue | System.Decimal | The minimum value. |
maxValue | System.Decimal | The maximum value. |
Returns
- System.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 | System.Decimal | The value to round. |
mode | RoundMode | The RoundMode to use. |
Returns
- System.Decimal:
A rounded number using the specified RoundMode.
Inherited Members
- System.Object.ToString()
- System.Object.Equals(System.Object)
- System.Object.Equals(System.Object, System.Object)
- System.Object.ReferenceEquals(System.Object, System.Object)
- System.Object.GetHashCode()
- System.Object.GetType()
- System.Object.MemberwiseClone()