ANP ANP - 6 months ago 45
ASP.NET (C#) Question

How to add doublequotes to a string that is inside a variable?

I have variable like:

string title = string.empty;

My need is that whatever string is passed to it I have to display the content inside a div with in a doublequotes .So I have written something like:

<div>"+ title +@"</div>

But how to add the doublequotes here? So that it will display like :

"How to add doublequotes"


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\"";