c# string.format 中使用$的坑

            string a = "hello}";
            string s = string.Format($"{a}");
上面这种情况,会报格式错误,会把hello}中的}当做一个字符串结束;

 结果: 

修改:
            string a = "hello}";
            string s = string.Format("{0}",a);

  结果:

使用了$ 实际上是字符串直接写入 如:$"{a}" 相当于$"{hello}}"从而导致格式错误

原文地址:https://www.cnblogs.com/darkif/p/14686884.html