Home » C#

C# | Uri.EscapeUriString() Method with Example

Uri.EscapeUriString() Method: Here, we are going to learn about the EscapeUriString() method of Uri class with example in C#.
Submitted by Nidhi, on March 28, 2020

Uri.EscapeUriString() Method

Uri.EscapeUriString() method is a static method that is used to convert specified Uri string in escaped representation.

Syntax:

    string Uri.EscapeUriString(string StrToEsc);

Parameter(s):

  • string StrToEsc – represents the specified Uri string to be converted in escaped format.

Return value:

The return type of this method is string, it returns escaped string.

Exception(s):

    System.ArgumentNullException;
    System.UriFormatException;

Example to demonstrate example of Uri.EscapeUriString() method

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {

        string uriString1 = "https://www.includehelp.com/index.html";
        string uriString2 = "https://www.includehelp.com/default.aspx";

        string resultString = "";

        resultString = Uri.EscapeUriString(uriString1);
        Console.WriteLine(resultString);

        resultString = Uri.EscapeUriString(uriString2);
        Console.WriteLine(resultString);
    }
}

Output

https://www.includehelp.com/index.html
https://www.includehelp.com/default.aspx


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.