Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# replace command
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01282218
Message ID:
01282272
Views:
8
>>string x = "I'm a boy";
>>"I'm a boy"
>>x.Replace("'","\'")
>>"I'm a boy" && output - wrong
>
>See code below:
>
>string s = "I'm a man";
>MessageBox.Show(s, "before");
>s = s.Replace("'", @"\'");
>MessageBox.Show(s, "after");
>
>
>The '\' is the escape character in C languages and is a very special character. You can escape the escape character by adding another escape character (s = s.Replace("'", "\\'");) or by using the @ infront of the string.

I'm trying this in the immediate window. This code gives me double \\. I need a single \ because this is for the Javascript. Perhaps I need to continue reading google links I found on "JavaScript single quote escape".
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform