How can I represent the "" characters within a string, for example i have a string
Mary said "The weather is nice today"
Of course i cant do something like this
string phrase = "Mary said "The weather is nice today""
Can anyone help me?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Jan 23, 2008, 1:47 PM
string myString = @"This is
a multiline string and
it will be stored like this.";
Pretty cool, lol.
kikiPosted Jan 23, 2008, 11:30 AM
AlanPosted Jan 22, 2008, 10:25 AM
If your string is 'verbatim' (i.e. preceded by the @ character), you can achieve the same thing by doubling the quotes:
string phrase = @"Mary said ""The weather is nice today""";
DavePosted Jan 22, 2008, 9:44 AM
string phrase = "Mary said \"The weather is nice today\"";
The slash followed by the inverted commas signals to the compiler that those inverted commas are not the end of the string and that they should be displayed as text.