Often we face situations where we need to add double quotes in a string.
In C# following is the way I have found out to add double quotes to a string.
1. Add escape characters to string by doubling them (verbatim string literal):
var str = @"""doublequotes""";
var string1 = @"firstpart ""part in quotes"" laterpart";
2. Add a normal string literal you escape them with a \:
string str = "\"doublequotes\"";
var string2 = "firstpart\"part in quotes\" laterpart";
When working on asp.net , you can try following.
string title = string.Format("<div>\"{0}\"</div>", "text to be filled");
You can also use:
&dquo;
<div>&dquo;"+ title +@"&dquo;</div>
or escape the double quote
\"
<div>\""+ title +@"\"</div>
No comments:
Post a Comment