How to convert float to string with 2 decimal places in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        float f = 83521.976f;
        
        string s = $"{f:F2}";

        Console.Write(s);
    }
}



/*
run:

83521.98

*/

 



answered Feb 12, 2023 by avibootz

Related questions

2 answers 388 views
4 answers 595 views
1 answer 323 views
2 answers 384 views
2 answers 379 views
2 answers 421 views
...