【发布时间】:2010-09-13 09:40:07
【问题描述】:
如何在 .NET 中格式化小数类型时去掉小数部分?我需要两种变体的通用语法。有什么温和的解决办法吗?
decimal a = 1.22M;
decimal b = 1.00M;
String.Format("${0}", a); // result is $1.22
String.Format("${0}", b); // result is $1.00, should be $1, HOW?
【问题讨论】:
-
String.Format("${0}", b.Replace(".00",string.Empty));
标签: c# .net formatting decimal