How can I decode HTML characters in C#?

c#

Question

I have email addresses encoded with HTML character entities. Is there anything in .NET that can convert them to plain strings?

1
374
11/5/2011 9:23:59 PM

Accepted Answer

You can use HttpUtility.HtmlDecode

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.

600
11/14/2011 5:11:17 PM

On .Net 4.0:

System.Net.WebUtility.HtmlDecode()

No need to include assembly for a C# project


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon