【发布时间】:2014-07-23 03:55:12
【问题描述】:
我正在尝试为数字添加逗号分隔符。我已经尝试过这里的建议:add commas using String.Format for number and 和这里:.NET String.Format() to add commas in thousands place for a number 但我无法让它工作 - 他们只是返回不带逗号的数字。我使用的代码在这里:
public static string addCommas(string cash) {
return string.Format("{0:n0}", cash).ToString();
}
我哪里错了?
谢谢。
更新:大家好,感谢您的帮助,但所有这些方法都返回相同的错误:“错误 CS1502:'BishopFlemingFunctions.addCommas(int)' 的最佳重载方法匹配有一些无效参数”(或变体取决于我使用的数字类型。)有什么想法吗?
【问题讨论】:
-
该错误消息表明您正在使用
int参数调用该方法,而您显示的是string参数。 -
嗨 - 是的,那是在尝试以下方法之后,而不是使用我的原始代码。
标签: asp.net