The integer nearest a. If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns a double instead of an integral type.
For examples and comprehensive usage information about this and other overloads of the Round method, see the erload:System.Math.Round reference page.
The following example demonstrates using the Math.Round(double)(double) method.
C# Example
using System; public class MathRoundExample { public static void Main() { Double d1 = Math.Round(4.4); Double d2 = Math.Round(4.5); Double d3 = Math.Round(4.6); Console.WriteLine("Math.Round(4.4) returns {0}", d1); Console.WriteLine("Math.Round(4.5) returns {0}", d2); Console.WriteLine("Math.Round(4.6) returns {0}", d3); } }
The output is
Math.Round(4.4) returns 4