471,056 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to concatenate a string whit "

Hi,
I have this problem:
In C# i have to concatenate a string "hi Carl" with
another string like this """, but C# gives me an error.
How can i concatenate a string with the " character?

Thank you
Alessandro Rossi
Nov 15 '05 #1
2 3042
Use an Escape Character before the quotation mark. The escape character is a
backslash '\'.

Example:

string str = "\"Hi Carl\"";

-Darrin
"Alessandro Rossi" <al**************@areaitsrl.com> wrote in message
news:09****************************@phx.gbl...
Hi,
I have this problem:
In C# i have to concatenate a string "hi Carl" with
another string like this """, but C# gives me an error.
How can i concatenate a string with the " character?

Thank you
Alessandro Rossi

Nov 15 '05 #2
Alessandro Rossi wrote:
Hi,
I have this problem:
In C# i have to concatenate a string "hi Carl" with
another string like this """, but C# gives me an error.
How can i concatenate a string with the " character?

Thank you
Alessandro Rossi


In the middle of a string, use the escape character, \, followed by a "
to add a " to the string.

E.g.

String FOOBAR = "\" To defend everything is to defend nothing \" -
Alexander the great";

Would be become: "To defend everything is to defend nothing" - Alexander
the great

Simon.

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Admir Hod?ic via AccessMonster.com | last post: by
1 post views Thread by news.wanadoo.nl | last post: by
5 posts views Thread by Generic Usenet Account | last post: by
14 posts views Thread by metamorphiq | last post: by
10 posts views Thread by Aaron Hoffman | last post: by
reply views Thread by leo001 | 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.