How to Specify the Number of Decimal Places for a Double value in C# ?

Below is a sample code snippet that demonstrates how the developers can specify the number of decimal places for a number declared as double in C#.

How to Specify the Number of Decimal Places for a Double value in C# ?

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace AbundantcodeConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            // How to Specify the Number of Decimal Places for a Double value in C# ?
            double Input = 1007.8675;
            Console.WriteLine(Input.ToString("F2", CultureInfo.InvariantCulture));
            Console.ReadLine();
        }
    }
    
}
1