I want to print two double quotes in C# as the output. How to do this?
I mean the output should be: \"\" Hello World \"\"
If you have to do this often and you would like this to be cleaner in code you might like to have an extension method for this.
This is really obvious code, but still I think it can be useful to grab and make you save time.
///
/// Put a string between double quotes.
///
/// Value to be put between double quotes ex: foo
/// double quoted string ex: "foo"
public static string PutIntoQuotes(this string value)
{
return "\"" + value + "\"";
}
Then you may call foo.PutIntoQuotes() or "foo".PutIntoQuotes(), on every string you like.
Hope this help.