For .net 4.0
Add a reference to System.net.dll
to the project with using System.Net;
then use the following extensions
// Html encode/decode
public static string HtmDecode(this string htmlEncodedString)
{
if(htmlEncodedString.Length > 0)
{
return System.Net.WebUtility.HtmlDecode(htmlEncodedString);
}
else
{
return htmlEncodedString;
}
}
public static string HtmEncode(this string htmlDecodedString)
{
if(htmlDecodedString.Length > 0)
{
return System.Net.WebUtility.HtmlEncode(htmlDecodedString);
}
else
{
return htmlDecodedString;
}
}