C# Uri CheckHostName

Description

Uri CheckHostName determines whether the specified host name is a valid DNS name.

Syntax

Uri.CheckHostName has the following syntax.


public static UriHostNameType CheckHostName(
  string name
)

Parameters

Uri.CheckHostName has the following parameters.

  • name - The host name to validate. This can be an IPv4 or IPv6 address or an Internet host name.

Returns

Uri.CheckHostName method returns A UriHostNameType that indicates the type of the host name. If the type of the host name cannot be determined or if the host name is null or a zero-length string, this method returns Unknown.

Example

The following example checks whether the host name is valid.


//from ww w .j  a  va  2 s  .c o m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Console.WriteLine(Uri.CheckHostName("www.java2s.com"));
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version