Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

c# ; "\" character

I get an error saying "Newline in constant" at the following line.
str_link=str_link.Replace ("\\","\");
Is there any way to solve this please?
[156 byte] By [rkbnair] at [2007-11-11 8:14:33]
# 1 Re: c# ; "\" character
Try placing an @ symbol in front of your quoted strings:

str_link=str_link.Replace(@"\\", @"\");

That tells C# not to interpret the backslash (\) as an escape character.
Phil Weber at 2007-11-11 23:13:22 >
# 2 Re: c# ; "\" character
No luck. Even after doing that all the \\ combinations are not replaced with \
rkbnair at 2007-11-11 23:14:22 >
# 3 Re: c# ; "\" character
Try this:
str_link = str_link.Replace("\\\\", "\\");
destin at 2007-11-11 23:15:20 >
# 4 Re: c# ; "\" character
Still no luck.
rkbnair at 2007-11-11 23:16:20 >
# 5 Re: c# ; "\" character
Please post a complete example, including the string you're trying to change, and how you're testing whether the characters have been successfully replaced.
Phil Weber at 2007-11-11 23:17:30 >