Simple Question..

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Guys,

Just wondering how we can build up a string which needs to contain speech
mark symbols in the text itself. For example doing something like..

exampleString = "Join the "2" groups together"

I am not sure how to do that in C#. Currently I can only able to acheive
something like this as a short hand..

exampleString = "Join the '2' groups together"

by using single quotes which I do not need..

Looking for valuable feedback on this simple query.

Thanks.

Irfan
 
Use backslash for escape chars:
exampleString = "Join the \"2\" groups together";

ok,
aq
 
Hi Irfan,

In addition to what Ahmed said you can also use a verbatim string. Just
prepend an @ symbol before the double quotes when beginning a string. If you
are using double quotes in the string you will need to escape them by
doubling them up. For instance:

string x = @"Hello ""World"" symbols : \ ^&* ";

I hope this helps.
----------------------
 
Back
Top