相关疑难解决方法(0)

用\替换\

我有一个字符串.我想搜索一个斜杠,然后用"\"(双斜杠)替换"\"(单斜杠).

string Method1(string s) 
{
     string upadtedString = s;
     if (s.Contains("\\"))
     {
      //do nothing
     }
     else if(s.Contains("\"))
     {
          string s1 = "\";
          string s2 = "\\";
          upadtedString.Replace(s1,s2);
          s = upadtedString;
     }
     return s;
 } 
Run Code Online (Sandbox Code Playgroud)

`

c# replace

1
推荐指数
1
解决办法
1327
查看次数

标签 统计

c# ×1

replace ×1