string.Format出现异常:输入字符串的格式不正确 Exception during StringFormat

错误信息:Exception during StringFormat:输入字符串的格式不正确

“System.FormatException”类型的未经处理的异常在 mscorlib.dll 中发生

其他信息: 输入字符串的格式不正确。

string s = string.Format("{return:"{0}"}", result);//这里报错  

后来发现是 占位符 result 里含有 "{}" 大括号导致。

解决办法:替换处理result,

用两个 { 或者 }连写表示单个。

或者其他办法

原文地址:https://www.cnblogs.com/jhlong/p/6525977.html