Remove '\' char from string c#

后端 未结 10 1023
谎友^
谎友^ 2020-12-15 03:16

I have the following code

string line = \"\"; 

while ((line = stringReader.ReadLine()) != null)
{
    // split the lines
    for (int c = 0; c < line.Len         


        
相关标签:
10条回答
  • 2020-12-15 03:42

    to remove all '\' from a string, simply do the following:

    myString = myString.Replace("\\", "");
    
    0 讨论(0)
  • 2020-12-15 03:45

    I have faced this issue so many times and I was surprised that many of these don't work.

    I simply deserialize the string with Newtonsoft.Json and I get cleartext.

    string rough = "\"call 12\"";
    rough = JsonConvert.DeserializeObject<string>(rough);
    
    //the result is: "call 12";
    
    0 讨论(0)
  • 2020-12-15 03:47

    Try using

    String sOld = ...;
    String sNew =     sOld.Replace("\\", String.Empty);
    
    0 讨论(0)
  • 2020-12-15 03:48
    line = line.Replace("\\", "");
    
    0 讨论(0)
提交回复
热议问题