Simple string replacement gone wrong
c#
Solution
The debugger shows strings as they would appear as C# string literals. That's why quotation marks are escaped. The string is not affected, though.
You can easily verify that by printing the string somewhere.
Quick demonstration:
In the debugging windows (purple) the string shows with escaped quotes (and surrounded by quoation marks, thus making it a C# string literal), while the output in the console (red) shows the actual contents.
Problem
I am trying to post a json string via a form submission ( multi-part encoding ) to an aspx page and send back a response based on the deserialized json string. ( I really need to do this via a form submission. no ajax ) I dunno why this doesn't work, but every time I try a simple string replacement to replace the single quotes with double quotes in the json string. It doesn't seem to be happening. Here's a summary of what I did. Here's the JSON string, ``` [["\n 22.02 13:15 \n ","\n \n \n \n ","\n \n \n \n ","\n \n \n "," \n Vereina\n ","\n \n ","\n 35 000\n ","\n 24.03.11\n ","\n Taiwan \n ","\n \n ","\n \n "]] ``` To send it via form data I replace all the " quotes with ' quotes like this, [['\n 22.02 13:15 \n ','\n \n \n \n ','\n \n \n \n ','\n \n \n ',' \n Vereina\n ','\n \n ','\n 35 000\n ','\n 24.03.11\n ','\n Taiwan \n ','\n \n ','\n \n ']] On the server side I am replacing the new lines since I don't need them, ``` [[' 22.02 13:15 ',' ',' ',' ',' Vereina ',' ',' 35 000 ',' 24.03.11 ',' Taiwan ',' ',' ']] ``` Then I use the C# string Replace method like this .Replace("'","\"") on the above, and what I get is ``` [[\" 22.02 13:15 \",\" \",\" \",\" \",\" Vereina \",\" \",\" 35 000 \",\" 24.03.11 \",\" Taiwan \",\" \",\" \"]] ``` I am observing this in the quick watch window of MS Visual Studio, also while debugging the code.