【问题标题】:Replace double consecutive single quotation mark [duplicate]替换双连续单引号[重复]
【发布时间】:2015-08-28 20:52:54
【问题描述】:

我正在尝试将双连续的单引号替换为空,如下所示:

//my string is " replace '' to null "
str.Replace("''", "null");
//now my string is " replace null to null "

但这正在发生:

//my string is " replace '' to null "
str.Replace("''", "null");
//sadly my string still is " replace '' to null "

有什么建议吗?

【问题讨论】:

    标签: c# string replace special-characters single-quotes


    【解决方案1】:

    string.Replace 不修改输入 string 而是返回一个新的。将其重新分配回您的变量以查看更改。

    str = str.Replace("''", "null");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 2021-08-12
      • 1970-01-01
      • 2014-10-05
      • 2018-11-18
      相关资源
      最近更新 更多