471,317 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

double quotations

Ant
Hi, how do you output a string that will be seen with double quotatios?

I'd like to display:

This is my "Value".

by doing something like:

string op = "This is my " + " + txtbox.text.ToString() + ";
Any clues would be gratefully accepted.

Ant
Feb 2 '06 #1
3 1378
Ant wrote:
Hi, how do you output a string that will be seen with double quotatios?

I'd like to display:

This is my "Value".

by doing something like:

string op = "This is my " + " + txtbox.text.ToString() + ";
Any clues would be gratefully accepted.


You need to escape the quotes:

string op = "This is my \"" + txtbox.Text + "\".";

To make things more obvious, here is something in the middle of a
string:

string x = "This gives a \"quoted\" example.";

See http://www.pobox.com/~skeet/csharp/strings.html for more
information.

Jon

Feb 2 '06 #2
string op = "This is my \"" + txtbox.text.ToString() + "\"";

i.e. \" is the escape character for " - read up on "string escape
characters" for more info

Marc
Feb 2 '06 #3
Should also be pointed out for completeness that verbatim string literals
(prefixed with @) need "" to represent a single double quote rather than an
escape.

string x = @"This gives a ""quoted"" example.";

"Ant" <An*@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Hi, how do you output a string that will be seen with double quotatios?

I'd like to display:

This is my "Value".

by doing something like:

string op = "This is my " + " + txtbox.text.ToString() + ";
Any clues would be gratefully accepted.

Ant

Feb 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Kondapanaidu | last post: by
55 posts views Thread by Martin Jørgensen | last post: by
67 posts views Thread by lcw1964 | last post: by
6 posts views Thread by jeff | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.