I want to store this:
<span class="icon phone">m</span>
in a string. How do I do this?
Tried: @"<span class="+"icon phone"+">m</span>";
Tried: @"<span class="+@"icon phone"+">m</span>";
Please help!
I want to store this:
<span class="icon phone">m</span>
in a string. How do I do this?
Tried: @"<span class="+"icon phone"+">m</span>";
Tried: @"<span class="+@"icon phone"+">m</span>";
Please help!
use single quotes, instead.
var html = "<span class='icon phone'>m</span>";
or double the quotes in a literal string
var html = @"<span class=""icon phone"">m</span>";
or escape the quote characters with the backslash character
var html = "<span class=\"icon phone\">m</span>";
How about
new XElement("span", new XAttribute("class", "icon phone"), "m").ToString()
You can also omit the @ and escape the double quote with a backslash \
:
"<span class=\"icon phone\">m</span>"
You can do so by typing " twice. It will appear once, inside a @-string.
So, in your case, to store:
<span class="icon phone">m</span>
Your string would be:
string s = @"<span class=""icon phone"">m</span>";
To save a quotes in a string, you have to mask it:
You can mask either by string mystring = @"<span class=""icon phone"">m</span>";
or by masking the quotes directly with a backslash (\)
string mystring = "<span class=\"icon phone\">m</span>";
.
Simply
String html = "<span class=\"icon phone\">m</span>"
Or you can use a String literal:
String html = @"<span class=""icon phone"">m</span>"
that's it.