Alex Rivera | Logout

C# two double quotes

Asked 2012-03-06T11:28:35.737
12

I want to print two double quotes in C# as the output. How to do this?

I mean the output should be: "" Hello World ""

Edit
Report

3 Answers

2

One way is to escape the quotes:

var greeting = "\"Hello World\"";
answered 2012-03-06T11:29:54.313
1

Escape them:

Console.WriteLine("\"Hello world\"");
answered 2012-03-06T11:30:05.247
1
Console.WriteLine("\"\"Hello world\"\"");

The backslash ('\') character precedes any 'special' character that would otherwise be interpreted as your code instead of as part of the string to be output. It's a way of telling the compiler to treat it as a character part of a string as opposed to a character that would otherwise have some sort of purpose in the C# language.

answered 2012-03-06T11:32:20.933

Your Answer