C# won't escape "\"? -


possible duplicate:
how use “\” in string without making escape sequence - c#?

why giving me error in c# when use string like: "\themes\default\layout.png"? @ "d" , "l" location? says unrecognized escape sequence. , how stop giving me error when use: "\"?

thans

you need escape additional \:

string value = "\\themes\\default\\layout.png"; 

or use @ symbol:

string value = @"\themes\default\layout.png"; 

which avoid doubling \.

or if dealing paths (which seems are) use path.combine method:

string value = path.combine(@"\", "themes", "default", "layout.jpg"); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -