错误 1 与“string.ToString(System.IFormatProvider)”最匹配的重载方法具有一些无效参数
错误 2 参数“1”: 无法从“string”转换为“System.IFormatProvider”
解决办法:
把你要转换的字符串先转换成具体的类型,例如int,double...,再format
Code
string ss = "123";
Response.Write( String.Format("{0:C}",Convert.ToInt32(ss))); //成功
Response.Write(String.Format("{0:C}", 123)); //成功
Response.Write(String.Format("{0:C}", ss)); //转换不成功
string ss = "123";
Response.Write( String.Format("{0:C}",Convert.ToInt32(ss))); //成功
Response.Write(String.Format("{0:C}", 123)); //成功
Response.Write(String.Format("{0:C}", ss)); //转换不成功