Decoding HTML Entities in C#:
C# provides a easy class named System.Net.WebUtility that includes the HtmlDecode method, which helps in decoding HTML-encoded strings.
using System;
class Program
{
    static void Main()
    {
        // HTML-encoded string
        string encodedString = "Hello <world>! This & is a test.";
        // Decoding the HTML-encoded string
        string decodedString = System.Net.WebUtility.HtmlDecode(encodedString);
        // Displaying the decoded string
        Console.WriteLine("Decoded String: " + decodedString);
    }
}
We hardcoded with an HTML-encoded string (encodedString) containing entities like "<" and "&". We also used the HtmlDecode method from System.Net.WebUtility to convert this encoded string into a normal string (decodedString). 
Output:
Decoded String: Hello <world>! This & is a test.


Comments (0)