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

c# uri.host_C#| Uri.IsAbsoluteUri属性与示例

燕鸿文
2023-12-01

c# uri.host

Uri.IsAbsoluteUri属性 (Uri.IsAbsoluteUri Property)

Uri.IsAbsoluteUri Property is the instance property of Uri class which used to check that given URI is absolute or not. This property returns a boolean value. If given Uri is absolute then it returns true otherwise it returns false. This property may generate System.InvalidOperationException exception.

Uri.IsAbsoluteUri属性是Uri类的实例属性,用于检查给定URI是否是绝对的。 此属性返回一个布尔值。 如果给定的Uri是绝对的,则返回true,否则返回false。 此属性可能会生成System.InvalidOperationException异常。

Syntax:

句法:

    public bool IsAbsoluteUri { get; }

Return value:

返回值:

The return type of this property is Boolean, it returns a Boolean value that is true if the Uri instance is absolute; otherwise, false.

此属性的返回类型为Boolean ,如果Uri实例为绝对值,则返回一个布尔值,该值为true 。 否则为false

Example to demonstrate example of Uri.IsAbsoluteUri Property

演示Uri.IsAbsoluteUri属性示例的示例

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        Uri domainUri;
        
        domainUri = new Uri("https://www.includehelp.com:8082");

        if (domainUri.IsAbsoluteUri)
            Console.WriteLine("Given Uri is absolute Uri");
        else
            Console.WriteLine("Given Uri is not absolute Uri");
        
    }
}

Output

输出量

Given Uri is absolute Uri

In the above program, we created an object of Uri class initialized with the website name with port number and here we checked given Uri is absolute or not using IsAbsoluteUri property of Uri class.

在上面的程序中,我们创建了一个Uri类的对象,该对象用带有端口号的网站名称初始化,在这里我们使用Uri类的IsAbsoluteUri属性检查给定的Uri是绝对的还是不绝对的。

Reference: Uri.IsAbsoluteUri Property

参考: Uri.IsAbsoluteUri属性

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

c# uri.host

 类似资料: