当前位置: 首页 > 工具软件 > URI.js > 使用案例 >

c# uri.host_C#| Uri.EscapeDataString()方法与示例

边霄
2023-12-01

c# uri.host

Uri.EscapeDataString()方法 (Uri.EscapeDataString() Method)

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

Uri.EscapeDataString()方法是静态方法,用于转换转义表示形式中的指定数据字符串。

Syntax:

句法:

    string Uri.EscapeDataString(string StrToEsc);

Parameter(s):

参数:

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

    字符串StrToEsc –表示要以转义格式转换的指定数据字符串。

Return value:

返回值:

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

此方法的返回类型为string ,它返回转义的字符串。

Exception(s):

例外情况:

    System.ArgumentNullException;
    System.UriFormatException;

Example to demonstrate example of Uri.EscapeDataString() method

演示Uri.EscapeDataString()方法示例的示例

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

翻译自: https://www.includehelp.com/dot-net/uri-escapedatastring-method-with-example.aspx

c# uri.host

 类似资料: