C#의 Uri.CheckHostName() 메서드는 지정된 호스트 이름이 유효한 DNS 이름인지 확인하는 데 사용됩니다.
구문
다음은 구문입니다 -
public static UriHostNameType CheckHostName (string host_name);
예시
이제 Uri.CheckHostName() 메서드를 구현하는 예를 살펴보겠습니다. -
using System;
public class Demo {
public static void Main(){
string strURI = "https://localhost";
Console.WriteLine("URI = "+strURI);
UriHostNameType res = Uri.CheckHostName(strURI);
Console.WriteLine("Host type = "+res);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
URI = https://localhost Host type = Unknown
예시
이제 Uri.CheckHostName() 메서드를 구현하는 또 다른 예를 살펴보겠습니다. -
using System;
public class Demo {
public static void Main(){
string strURI = "www.tutorialspoint.com";
Console.WriteLine("URI = "+strURI);
UriHostNameType res = Uri.CheckHostName(strURI);
Console.WriteLine("Host type = "+res);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
URI = www.tutorialspoint.com Host type = Dns