static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder(); 
            string test = "124454664{0}89jnhb";
            string formattedMessage = string.Format(test, args);
   
        }

主要原因是字符串中有{}, 被string.Format调用时报错。

Replace即可。

            StringBuilder sb = new StringBuilder(); 
            string test = "124454664{0}89jnhb";
            test = test.Replace("{", "[").Replace("}", "]"); 
            string formattedMessage = string.Format(test, args);
   

或者 将 { 替换为 {{

相关文章:

  • 2021-08-24
  • 2022-01-16
  • 2021-05-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2021-09-26
  • 2022-12-23
  • 2021-05-11
  • 2020-11-02
  • 2022-12-23
相关资源
相似解决方案