How to format data of type double to display 2 decimal places in C# ?

You can easily format data of type double to display 2 decimal places in C# using the format specifier {0:#.##}.

How to format data of type double to display 2 decimal places in C# ?

Below is a sample sourcecode to demonstrate formatting data of type double to display 2 decimal places in C#

using System;
namespace ConsoleApplication1
{ 
    class Program
    {
        static void Main(string[] args)
        {
            double data = 12890.78654;
            Console.WriteLine("{0:#.##}", data);
            Console.ReadLine();
        }
    }
}