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