c# uri.host
Uri.CheckHostName()方法 (Uri.CheckHostName() Method)
Uri.CheckHostName() method is a static method that returns the object of UriHostNameType enum than we need to compare returned enum object with UriHostNameType.Dns. If both are equal then the condition will be true otherwise it will be false.
Uri.CheckHostName()方法是一個靜態方法,該方法返回UriHostNameType枚舉的對象, 而不是我們需要將返回的枚舉對象與UriHostNameType.Dns進行比較。 如果兩者相等,則條件為true,否則為false 。
Syntax:
句法:
UriHostNameType Uri.CheckHostName(string Hostname);
Parameter(s):
參數:
string Hostname – represents the hostname to be checked, whether it is valid or not.
字符串Hostname –表示要檢查的主機名,無論它是否有效。
Return value:
返回值:
The return type of this method is UriHostNameType, it returns an object of UriHostNameType enum, that is compared with UriHostNameType.Dns to check DNS is valid or not.
此方法的返回類型為UriHostNameType ,它返回UriHostNameType枚舉的對象,該對象與UriHostNameType.Dns進行比較以檢查DNS是否有效。
Example to demonstrate example of Uri.CheckHostName() method
演示Uri.CheckHostName()方法示例的示例
using System;
class UriExample
{
//Entry point of Program
static public void Main()
{
UriHostNameType hostNameType;
hostNameType =Uri.CheckHostName("www.includehelp.com");
if (hostNameType == UriHostNameType.Dns)
{
Console.WriteLine("It is valid DNS");
}
else
{
Console.WriteLine("It is not valid DNS");
}
hostNameType = Uri.CheckHostName("www.includehelp!com");
if (hostNameType == UriHostNameType.Dns)
{
Console.WriteLine("It is valid DNS");
}
else
{
Console.WriteLine("It is not valid DNS");
}
}
}
Output
輸出量
It is valid DNS
It is not valid DNS
翻譯自: https://www.includehelp.com/dot-net/uri-checkhostname-method-with-example.aspx
c# uri.host