本文共 1749 字,大约阅读时间需要 5 分钟。
c# uri.host
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 DNSIt is not valid DNS
翻译自:
c# uri.host
转载地址:http://zuxzd.baihongyu.com/