MathRound Method (Decimal, MidpointRounding) |
Rounds a decimal value to the nearest integer. A parameter specifies how to round the value if it is midway between two other numbers.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static decimal Round(
decimal d,
MidpointRounding mode
)
Parameters
- d
- Type: SystemDecimal
A decimal number to be rounded. - mode
- Type: SystemMidpointRounding
Specification for how to round d if it is midway between two other numbers.
Return Value
Type:
DecimalThe integer nearest
d. If
d is halfway between two numbers, one of which is even and the other odd, then
mode determines which of the two is returned.
Exceptions Exception | Condition |
---|
ArgumentException | mode is not a valid value of MidpointRounding. |
OverflowException | The result is outside the range of a Decimal. |
See Also