By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

How to replace " with " character in String

P: 6
Suppose I have the following string whch is part of an xml string:
String s= "Script Id="Test" "

And I need to get
s= "Script Id="Test" "

Can anyone tell me how this can acheived?

Thanks,
jmash
Feb 13 '08 #1
Share this Question
Share on Google+
2 Replies


Shashi Sadasivan
Expert 100+
P: 1,435
Have you tried the Replace?

String s= "Script Id="Test" ";
s = s.Replace(""", "\"");

backslash is used as an escape character.
Note the 3 quotation marks in the second argument of the Replace method
Feb 13 '08 #2

DrBunchman
Expert 100+
P: 979
Suppose I have the following string whch is part of an xml string:
String s= "Script Id="Test" "

And I need to get
s= "Script Id="Test" "

Can anyone tell me how this can acheived?

Thanks,
jmash
No problem JMash,

To insert a double quotation inside a string you need to use two double double quotation marks next to each other. So you would replace all instances of &quot with "". Try this:

s = s.Replace("&quot", """")

This little rule about quote marks applies to apostrophe's as well where they are used as string delimiters (for example in SQL) and is an important thing to be aware of.

Give this a try and let me know if it helps,

Dr B
Feb 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.