How to concatenate a string whit "

  • Thread starter Thread starter Alessandro Rossi
  • Start date Start date
A

Alessandro Rossi

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
 
Use an Escape Character before the quotation mark. The escape character is a
backslash '\'.

Example:

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

-Darrin
 
Alessandro said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top