I have a string variable such as this:
string title = string.empty;
I have to display the content of whatever is passed to it inside a div within double quotes. I have written something like this:
...
...
<div>"+ title +@"</div>
...
...
How can I add the double quotes here? So that it will display like:
"How to add double quotes"
You need to escape them by doubling them (verbatim string literal):
string str = @"""How to add doublequotes""";
Or with a normal string literal you escape them with a \
:
string str = "\"How to add doublequotes\"";
Update:
With C# 11, you can use raw string literals:
string str = """
"How to add doublequotes"
"""