m in line. How to do it? Tried: @"

Double quotes inside an HTML string

I want to save this:

<span class="icon phone">m</span> 

in line. How to do it?

Tried: @"<span class="+"icon phone"+">m</span>";

Tried: @"<span class=" +@ "icon phone"+">m</span>";

Please, help!

+4
source share
7 answers

use single quotes.

 var html = "<span class='icon phone'>m</span>"; 

or double quotes in a string string

 var html = @"<span class=""icon phone"">m</span>"; 

or remove quotation marks with backslash character

 var html = "<span class=\"icon phone\">m</span>"; 
+6
source

You can also omit @ and avoid double quotation marks using the backslash \ :

 "<span class=\"icon phone\">m</span>" 
+1
source

What about

 new XElement("span", new XAttribute("class", "icon phone"), "m").ToString() 
+1
source

You can do this by typing "twice". It will appear once inside the @ -line.

So, in your case, to save:

 <span class="icon phone">m</span> 

Your line will be:

 string s = @"<span class=""icon phone"">m</span>"; 
0
source

To save quotation marks in a string, you must mask it:

You can mask either string mystring = @"<span class=""icon phone"">m</span>"; , or by masking quotes directly using the backslash (\) string mystring = "<span class=\"icon phone\">m</span>"; .

0
source

Just

 String html = "<span class=\"icon phone\">m</span>" 

Or you can use a string literal:

 String html = @"<span class=""icon phone"">m</span>" 

what he.

0
source

try the following:

  string str="<span class=\"icon phone\">m</span>"; 
0
source

All Articles