How can I replace the “\” in a string with a double slash “\\”?
I tried String.Replace(“\”,”\\”) but then intellisense stops working 🙁
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try:
This is because a character can follow \, which makes a special character. \” means put a literal double quote in the string, rather than close it.
Here are some common ones:
\n– Line feed\r– Carriage return (Windows newlines are\r\n)\t– TabThe other answers, which say to use
@"\"are right and easier to understand, so should probably be used instead.