C# Decimal Round(Decimal)

Description

Decimal Round(Decimal) rounds a decimal value to the nearest integer.

Syntax

Decimal.Round(Decimal) has the following syntax.


public static decimal Round(
  decimal d
)

Parameters

Decimal.Round(Decimal) has the following parameters.

  • d - A decimal number to round.

Returns

Decimal.Round(Decimal) method returns The integer that is nearest to the d parameter. If d is halfway between two integers, one of which is even and the other odd, the even number is returned.

Example

The following code shows how to use Decimal.Round(Decimal) method.


using System;/*from   ww w .  java2  s . c o m*/

public class Example
{
    public static void Main()
    {
           Console.WriteLine(Decimal.Round(2.3M)); 
    }
} 

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version