Reputation: 231
I know that c# just prints the data inside double quotes:
Console.WriteLine("These two double quotes are removed when i am printed");`
And the output of it in console will be:
These two double quotes are removed when i am printed
But what I want to print on console is the same thing with double quotes:
"These two double quotes are removed when i am printed"
How do I do this. I am trying so because i have to write this output to a file where double quotes have significance.
Upvotes: 9
Views: 30777
Reputation: 4808
You need to escape the characters using \
:
Console.WriteLine("\"These two semi colons are removed when i am printed\"");
Also, the characters you are referring to ("
) are not semi-colons but quotation marks. A semi-colon is ;
.
Upvotes: 21
Reputation: 24579
Just add \
. See the String literals article
Console.WriteLine("\"These two semi colons are removed when i am printed\"");
Upvotes: 5