How to get floats value without including exponential notation

后端 未结 5 1068
自闭症患者
自闭症患者 2021-01-02 01:04

In C#, is it possible to perform ToString on a float and get the value without using exponentials?

For example, consider the following:

float dummy;
         


        
5条回答
  •  醉梦人生
    2021-01-02 01:38

    Try this

    Console.WriteLine(dummy.ToString("F"));
    

    You can also specify number of decimal places. For example F5, F3, etc.

    Also, you can check custom format specifier

    Console.WriteLine(dummy.ToString("0.#########"));
    

提交回复
热议问题