Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# replace command
Message
De
16/01/2008 11:40:59
Timothy Bryan
Sharpline Consultants
Conroe, Texas, É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:
01282291
Vues:
10
This message has been marked as a message which has helped to the initial question of the thread.
Naomi,
the "\" character might be the actual problem. Try prefacing it with @"\"
Tim

>>>>Maybe try to break it up a little to debug. Something like so (this is in VB):
>>>>
>>>>
>>>>Dim x As String
>>>>x = "I'm a boy"
>>>>x = Server.URLEncode(x)
>>>>x = x.Replace("'","\'")
>>>>
>>>>
>>>>View x after every line. Does this help at all?
>>>
>>>No, I've tried. The Replace doesn't work. I believe it's because the first character is a character (char), but the second is a string. In my case I need to replace string (1 char) with 2 chars.
>>>
>>>Do you know any other method before I try to search online?
>>>
>>>I did try in the immediate window a simple replace and it's not working.
>>
>>So the encoding is working correctly - it's just the Replace that isn't. Let's simplify the problem then:
>>
>>
>>Dim x As String
>>x = "I'm a boy"
>>x = x.Replace("'","\'")
>>'x is equal to "I\'m a boy"
>>
>>
>>Does this work for you? It works for me.
>
>I've just tried in the immediate window:
>
>
>string x = "I'm a boy";
>"I'm a boy"
>x.Replace("'","\'")
>"I'm a boy" && output - wrong
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform