how to append " in string in c#
for writing images on a html page i want to write only " after closing are anyone tell me about this then how i can write this
means to say that
<img src = " <开发者_运维知识库% code is here %> " />
It can be done like this, by escaping the quote with \"
String myStr = "Hello World";
myStr += "\"";
You can also use this syntax:
var s = @"a string with ""double quotes";
s += @"""";
If using variable or expression use this:
<% string imagePath = @"c:\Images\wallpaper.jpg"; %>
<img src = "<%=imagePath%> "/>
If using statement use this:
<img src = "<%
string imagePath = @"c:\Images\wallpaper.jpg";
Response.Write(imagePath);
%>">
string s = "\"";
" is a special char. You need to prefix it with a \ otherwise it will interprete the " as the end of the string.
Details here: http://blogs.msdn.com/csharpfaq/archive/2004/03/12/88415.aspx
To put double quotes into a string you have to escape them with a backslash. E.g.:
String myString = "hello \" double quotes";
精彩评论