Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

escape sequence in C#

Status
Not open for further replies.

tondarb

Programmer
Oct 8, 2003
37
US
Hi,

May be this is an easy thing for you, I am struggling with this as I am a beginner.I am trying to pass "'" to the javascript.

Example: "Nina's doll"

I must pass this sentence to javascript. I tried like this from C#

test=test.Replace("'","\'");

and also like this

test=System.Text.RegularExpressions.Regex.Replace(test,"'","\'");

If I give something else in the replace function insteadof "\'" it is working.


Please help me.


 
...Try with "\\'" or @"\'". Backslah is an escape character in C# strings and in your case you are escaping "'" and that's why result is same string ("\'" == "'"). If you want to insert backslah somwhere in string use "\\".

Cheers,
Batvanko ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top