String format for only one decimal place?

前端 未结 6 1684
天命终不由人
天命终不由人 2020-12-10 10:44

I\'d like to dispaly only one decimal place. I\'ve tried the following:

string thevalue = \"6.33\";
thevalue = string.Format(\"{0:0.#}\", thevalue);
         


        
6条回答
  •  鱼传尺愫
    2020-12-10 11:15

    Here is another way to format floating point numbers as you need it:

    string.Format("{0:F1}",6.33);
    

提交回复
热议问题