如果我只想显示不是整数的小数,那么设置小数格式的最佳方法是什么。
例如:
decimal amount = 1000M
decimal vat = 12.50M
当我想要格式化时:
Amount: 1000 (not 1000.0000)
Vat: 12.5 (not 12.50)
最佳答案
decimal one = 1000M;
decimal two = 12.5M;
Console.WriteLine(one.ToString("0.##"));
Console.WriteLine(two.ToString("0.##"));
关于c# - 如果有任何格式,我该如何格式化以仅包括小数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/216538/