HelloWorld HelloWorld - 5 months ago 36
C# Question

Remove " and \ using Replace

string a = "\"address\": {\r\n \"label\":"

string b = "{\r\n \"label\":"

a.replace(""\"address\": ", "")

The goal is to remove the data ""\"address\":" and retrieve the same value as string b?


When you want to parse a double quote in a string you must place a slash before the quote: "\"" Not like it's needed in this example anyway, since it is already embbeded in the string. The solutionn to your question:

        string a = "\"address\": {\r\n  \"label\":";
        string b = "{\r\n  \"label\":";
        a = a.Replace("\"address\": ", "");