网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  c# string.format 中使用$的坑

c# string.format 中使用$的坑

分类: IT文章 • 2023-11-22 10:28:19
            string a = "hello}";
            string s = string.Format($"{a}");
上面这种情况,会报格式错误,会把hello}中的}当做一个字符串结束;

 结果: c# string.format 中使用$的坑

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

  结果:c# string.format 中使用$的坑

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

相关推荐

  • 审批中关于e.Url的说明和使用
  • C#中的方括号[](特性、属性)
  • ansible 剧本 ansible的管理与剧本 ansible的剧本playbook 执行剧本 简单的copy剧本 剧本的查看输出的过程 在剧本中使用自定义变量 使用内置的变量 利用template模块下发可变的变量配置 下发的变量的判断的语法 剧本的通知和下发机制 用roles来模板换剧本,可以自己组合模板 tasks的任务编排模块 执行监督的模块 roles下的自定义变量模块 roles使用copy,和scripts模块 roles中的template模块 roles的notify变动通知执行模块
  • vue中