Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best datatype for storing html

Tags:

c#

I need to store HTML in one of the varibles in my class, which datatype would you suggest? Will string be ok or is there any special datatype I can use for this kind of operation.

like image 272
Jay Avatar asked Sep 01 '25 17:09

Jay


1 Answers

string if you're storing the raw HTML.

If you were planning on storing an object-representation of the HTML, then obviously you would use that object.

However, if it's just the raw HTML string, you'd use a string. There's nothing specially suited to any type of string content.

Actually, there kindof is, but it has a specialist usage to represent already-encoded HTML data that should not be encoded again (generally used to output raw HTML in ASP.NET). This isn't what you want, but just so that this answer is complete - HtmlString.

like image 83
Rudi Visser Avatar answered Sep 04 '25 10:09

Rudi Visser