【问题标题】:string replace single quote to double quote in C#字符串在C#中将单引号替换为双引号
【发布时间】:2011-07-08 12:54:40
【问题描述】:

如何在 C# 中将字符串中的单引号 (') 替换为双引号 (")?

【问题讨论】:

    标签: c# string replace


    【解决方案1】:

    您需要为引号符号使用正确的转义序列,您可以找到更多关于转义序列的信息here

    String stringWithSingleQuotes= "src='http://...';";
    String withDoubleQuotes = stringWithSingleQuotes.Replace("'","\"");
    

    【讨论】:

      【解决方案2】:
      var abc = "hello the're";
      abc = abc.Replace("'","\"");
      

      【讨论】:

        【解决方案3】:
        string str;
        str=strtext.Replace('"','\'');
        

        【讨论】:

        • 我们是否用您的代码替换“与”?我认为应该相反。
        猜你喜欢
        • 2017-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-18
        • 1970-01-01
        • 1970-01-01
        • 2016-09-23
        相关资源
        最近更新 更多