How do I format a C# decimal to remove extra following 0's?

后端 未结 11 1879
长发绾君心
长发绾君心 2021-01-31 07:40

I want to format a string as a decimal, but the decimal contains some following zeros after the decimal. How do I format it such that those meaningless 0\'s disappear?

11条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-31 08:16

    string s = d.ToString("0.#############################");
    

提交回复
热议问题