我有一个问题。找不到格式,转换成十进制为货币字符串没有前导零如果是小于1。
I have an issue. Cannot find format which converts decimal to currency string without leading zeros if it is less that 1.
例如。
decimal d = 0.14M;
d.ToString("C"); // Translates to $0.14 But I need to get $ .14
是否有一些特殊的precision符丰富这样的效果只是调用toString?
Are there some special precision specifiers to rich such an effect just calling ToString ?
试试这个:
string result = String.Format("{0:#.0}", d);
来源: http://www.csharp-examples.net/string-format备有双人床/
下一篇:修改R函数中的变量变量、函数