Home » C#

C# | Uri.EscapeDataString() Method with Example

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

Uri.EscapeDataString() Method

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

Syntax:

    string Uri.EscapeDataString(string StrToEsc);

Parameter(s):

  • string StrToEsc – represents the specified data 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.EscapeDataString() 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.EscapeDataString(uriString1);
        Console.WriteLine(resultString);

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

Output

https%3A%2F%2Fwww.includehelp.com%2Findex.html
https%3A%2F%2Fwww.includehelp.com%2Fdefault.aspx





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.