Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# replace command
Message
De
16/01/2008 11:27:09
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
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:
01282285
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.

Had to one up with with "I'm a man", huh? ;-)
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform