How can I decode HTML characters in C#?
If there is no Server context (i.e your running offline), you can use HttpUtility.HtmlDecode.
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.
As @CQ says, you need to use HttpUtility.HtmlDecode, but it's not available in a non-ASP .NET project by default.
For a non-ASP .NET application, you need to add a reference to System.Web.dll
. Right-click your project in Solution Explorer, select "Add Reference", then browse the list for System.Web.dll
.
Now that the reference is added, you should be able to access the method using the fully-qualified name System.Web.HttpUtility.HtmlDecode
or insert a using
statement for System.Web
to make things easier.
On .Net 4.0:
System.Net.WebUtility.HtmlDecode()
No need to include assembly for a C# project