Mohanapriya R Mohanapriya R
Updated date Apr 08, 2024
In this article, we will learn how to change special codes in web addresses to normal text in C#.

Converting URL Encoded Strings to Normal Strings

Let's create a simple C# program to showcase the conversion of URL-encoded strings to plain text using the HttpUtility.UrlDecode method. Here's the code:

using System;
using System.Web;

class Program
{
    static void Main()
    {
        // URL encoded string
        string encodedString = "Hello%20World%21%26";

        // Decode the URL encoded string
        string decodedString = HttpUtility.UrlDecode(encodedString);

        // Output the results
        Console.WriteLine("Encoded String: " + encodedString);
        Console.WriteLine("Decoded String: " + decodedString);
    }
}

Output:

Encoded String: Hello%20World%21%26
Decoded String: Hello World!&

In this example, we start with a URL encoded string "Hello%20World%21%26" and use HttpUtility.UrlDecode to convert it back to the original text, which results in "Hello World!&".

Comments (0)

There are no comments. Be the first to comment!!!