Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# replace command
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01282218
Message ID:
01282272
Vues:
9
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform