Home > DeveloperSection > Forums > Writing “\\” inside a string
Babe Zaharias
Babe Zaharias

Total Post:19

Points:133
Posted on    July-08-2013 8:16 AM

 C# C# 
Ratings:


 1 Reply(s)
 850  View(s)
Rate this:
Hi Developers!

I want to do something like:

string s = "\\blabla";

when you write "\" it means there will only be a single '\'. How do I write the string so there will actually be 2 '\' meaning "\" ?



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    July-08-2013 8:27 AM

Hi Babe!

This works without a problem:

string s = "//blabla";
If you mean the backslash instead, you can use a verbatim string literal (using the @ symbol to avoid processing escape symbols):

string s = @"\\blabla";
Alternatively you can escape the escape character itself:

string s = "\\\\blabla";

Don't want to miss updates? Please click the below button!

Follow MindStick