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

c# uri.host

Uri.IsLoopback属性 (Uri.IsLoopback Property)

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

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

Syntax:

句法:

    public bool IsLoopback { get; }

Return value:

返回值:

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

此属性的返回类型为Boolean ,如果此Uri引用本地主机,则返回一个布尔值,该值为true 。 否则为false

Example to demonstrate example of Uri.IsLoopback Property

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

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("http://localhost");

        if (domainUri.IsLoopback)
            Console.WriteLine("Given Uri is a reference of localhost");
        else
            Console.WriteLine("Given Uri is a not reference of localhost");


        if (domainUri1.IsLoopback)
            Console.WriteLine("Given Uri is a reference of localhost");
        else
            Console.WriteLine("Given Uri is a not reference of localhost");
    }
}

Output

输出量

Given Uri is a not reference of localhost
Given Uri is a reference of localhost

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 reference of localhost/loopback using IsLoopback property of Uri class.

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

Reference: Uri.IsLoopback Property

参考: Uri.IsLoopback属性

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

c# uri.host

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值