Convert Strings to HTML Decode in Cin C#
In C#, you can use the System.Net.WebUtility
class to decode HTML entities. The HtmlDecode
method within this class is specifically designed for this purpose.
using System;
class Program
{
static void Main()
{
// Sample HTML-encoded string
string encodedString = "Hello <World>";
// Decode the HTML-encoded string
string decodedString = System.Net.WebUtility.HtmlDecode(encodedString);
// Display the original and decoded strings
Console.WriteLine("Original String: " + encodedString);
Console.WriteLine("Decoded String : " + decodedString);
}
}
We have defined an HTML-encoded string ("Hello <World>"
). Using WebUtility.HtmlDecode
, we decoded this string and store the result in another variable (decodedString
).
Output:
Original String: Hello <World>
Decoded String : Hello <World>
Comments (0)