用replace将 ' 替换成 \'

解决方案 »

  1.   


    string a = "aaaaaa'dddddd";
    Response.Write(a.Replace("'","\\'"));
      

  2.   

    ' '是不允许空字符的。
    [string].Replace(" ",@"\");
      

  3.   

    string txt="this is it's tail.";
    txt=txt.Replace("'","\\'");
    \是特殊符号,要使用\来进行转义。
      

  4.   


            string a = "'wer'wer'wer'";
            a= a.Replace("'", "\\'");
            Response.Write(a);
      

  5.   

    Response.Write(a.Replace("'","\\'"));
      

  6.   


    string str = @"'\'\'\";
    str.Replace("'", @"\'")
      

  7.   

    string str = @"an'd'yba'ng'sff";
    str.Replace("'", "\\");