I’m porting some Delphi code to C#. I can’t find a similar function to Delphi’s FormatFloat.
I’ve got this line of code in Delphi
str := FormatFloat('000', 1);
which assigns to str the string '001'. Note the leading zeros.
How can I achieve the same result in C#?
You use string.Format() with custom numeric format strings. For example: