Posted: 9/3/2010
hey hi, i want to replace \\ with \ in a string.
i m doing this
string str = "Shaitender\\MONU".Replace("\\",@"\"); Response.Write(str);
But in Quick watch it still showing "Shaitender\\MONU". but on the page it's showing "Shaitender\MONU".
Quick Watch Output :
Html OuptutShaitender\MONU
Why both output are different any idea? i did some searching on google but still unable to figure out concept of Escape Characters
the Problem is when im passing the string it contains \\ in it . Is there any other possible way to Replace it .Tired Regex too but still not working .
Escape characters are still mystery for me :) !!!
Refer http://codeasp.net/blogs/raghav_khunger/microsoft-net/787/c-how-to-replace-double-backward-slash-with-single-backward-slash for replacement code.
Also for your second query you will always see double backward slash there where you are seeing:
You need to click the "Text Visualizer" icon in order to see the actual output: