I want to print two double quotes in C# as the output. How to do this?
I mean the output should be: \"\" Hello World \"\"
Use a backslash before the double quotes: \"
Escape them:
Console.WriteLine("\"Hello world\"");
Using a @-char before the 'normal' double quotes will result in printing every special char between those dubble quotes
string foo = @"foo "bar"";
StringBuilder sb = new StringBuilder();
sb.Append("\"Hello World \"");
string s = sb.ToString();
you can output with the @
, which will automatically escape special characters.
string output = "\"\" Hello World \"\"";
string output = @""""" Hello World """"";