欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2024-02-13 20:50:58
...

c# uri.host

Uri.GetLeftPart()方法 (Uri.GetLeftPart() Method)

Uri.GetLeftPart() method is an instance method that is used to get a specified part from the given URI based on passed UriPartial enum.

Uri.GetLeftPart()方法是一个实例方法,用于基于传递的UriPartial枚举从给定URI中获取指定部分。

Syntax:

句法:

    string Uri.GetLeftPart (UriPartial Part);

Parameter(s):

参数:

  • Part – represents UriPartial to get specified part from Uri.
  • 零件 –表示从Uri获取指定零件的UriPartial。

Return value:

返回值:

The return type of this method is string, it returns string value to represent specified part of Uri.

该方法的返回类型为string ,它返回表示Uri指定部分的字符串值。

Exception:

例外:

    System.ArgumentException;
    System.InvalidOperationException;

Example to demonstrate example of Uri.GetLeftPart() method

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

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        // Create an object of Uri
        Uri Address;

        Address = new Uri("https://www.includehelp.com/index.html#search");

        Console.WriteLine(Address.GetLeftPart(UriPartial.Authority));
        Console.WriteLine(Address.GetLeftPart(UriPartial.Path));
        Console.WriteLine(Address.GetLeftPart(UriPartial.Query));
        Console.WriteLine(Address.GetLeftPart(UriPartial.Scheme));
    }
}

Output

输出量

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


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

c# uri.host