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

c# uri.host_C#| 具有示例的Uri.IsFile属性

沈子昂
2023-12-01

c# uri.host

Uri.IsFile属性 (Uri.IsFile Property)

Uri.IsFile Property is instance property of Uri class which used to check that specified Uri is a file Uri or not. This property returns a boolean value. If specified Uri is a file Uri then it returns true otherwise it returns false. This property may generate System.InvalidOperationException exception.

Uri.IsFile属性是Uri类的实例属性,用于检查指定的Uri是否是文件Uri。 此属性返回一个布尔值。 如果指定的Uri是文件Uri,则它返回true,否则返回false。 此属性可能会生成System.InvalidOperationException异常。

Syntax:

句法:

    public bool IsFile { get; }

Return value:

返回值:

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

此属性的返回类型为Boolean ,如果Uri是文件URI,则返回一个布尔值,该值为true 。 否则为false

Example to demonstrate example of Uri.IsFile Property

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

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        Uri domainUri;
        Uri domainUri1;

        domainUri = new Uri("https://www.includehelp.com:8082");
        domainUri1 = new Uri("file://myServer/article.text");

        if (domainUri.IsFile)
            Console.WriteLine("Given Uri is a file Uri");
        else
            Console.WriteLine("Given Uri is not a file Uri");


        if (domainUri1.IsFile)
            Console.WriteLine("Given Uri is a file Uri");
        else
            Console.WriteLine("Given Uri is not a file Uri");
    }
}

Output

输出量

Given Uri is not a file Uri
Given Uri is a file Uri

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

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

Reference: Uri.IsFile Property

参考: Uri.IsFile属性

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

c# uri.host

 类似资料: