tags:

views:

110

answers:

2

HI, I've got a really seriously question.

I need to send HTML code, so I have to load html into string, and this obvious doesn't work if I can't interpret them well, how can I store it natively?

Thanks for your help

+6  A: 

Strings and HTML should be fine. The only complication is escaping, which is made easier using verbatim string literals (@"..."). Then you just double any double-quotes:

string body = @"<html><body>
<a href=""foo.bar"" class=""blap"">blip</a>
...
</body></html>";
Marc Gravell
So @"" is called a verbatim string literal? I'm gonna upvote because up until now I've been saying `use an @(at) sign before the quotes`. Thank you @Marc.
Marko
@marko - yes, that is the official name. Yours works too, though ;)
Marc Gravell
I'm not sure, but it just not working with my HTML coding, cos I've tried this, while the double quote still can't be properly interpreted . Could you try a more complex block of html? Like a whole page? Because the small block works on my computer either.
@user469652 - I think you need to find an example that doesn't work. As HTML is fine, honestly. If is doesn't work, you've either missed the @ or a "
Marc Gravell
A: 

If you html code is in a file you can File.ReadAllText

string myString = System.IO.File.ReadAllText("path to the file");
Preet Sangha