Code Snippets by Patrik

How to decode HTML characters in C#

To decode HTML you can use HttpUtility.HtmlDecode

string a = "Here's how to";
string b = HttpUtility.HtmlDecode(a);
Response.Write(b);

This will output

Here's how to

If you are using .NET 4.0+ you can also use WebUtility.HtmlDecode which does not require an extra assembly reference as it is available in the System.Net namespace.

Comments

Leave a Comment

All fields are required. Your email address will not be published.