using System;
// Class to create analog for JS toFixed method
public static class AnalogForJStoFixed
{
public static string toFixed(this double number, int decimals)
return number.ToString("N" + decimals);
}
public class Program
public static void Main()
double d = 235.785;
// achieve the goal with custom static class created especially to make JS toFixed() method's analog.
var res1 = d.toFixed(5);
// without custom class we can just do as follows
var res2 = d.ToString("N2");
Console.WriteLine(res1);
Console.WriteLine(res2);