Format Double and round - CSharp System

CSharp examples for System:Double

Description

Format Double and round

Demo Code


using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;/*www  .  j ava 2  s  .c o  m*/

public class Main{
        public static String FormatDouble(double d, int decimalPlaces)
        {
            return Convert.ToString(Math.Round(d, 2), System.Globalization.CultureInfo.InvariantCulture);
        }
        public static String FormatDouble(double d)
        {
            return Convert.ToString(d, System.Globalization.CultureInfo.InvariantCulture);
        }
}

Related Tutorials