Search This Blog

Monday, November 26, 2012

Math.Round

C#  > System > Math class > Round

Rounds a double-precision floating-point value to a specified number of fractional digits.

Example:

using System;

public class Round
{
   public static void Main()
   {
      double value = 4.254;
      Console.WriteLine("{0} => {1}", value, Math.Round(value, 0));
   }
}
// Result
// 4.254 --> 4