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

后端 未结 11 1874
长发绾君心
长发绾君心 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:14

    Quite a few answers already. I often refer to this cheat sheet: http://blog.stevex.net/string-formatting-in-csharp/

提交回复
热议问题