DNS Methods in .NET

Examples using some common methods in the System.Net.Dns namespace in the .NET Framework.

Method Parameter Object Type Returns Info
GetHostAddresses String Array of IPAddress objects Passing an empty string “” returns a list of IP addresses assigned to the local computer
GetHostEntry String
– or –
IPAddress
IPHostEntry object Passing an IP address does a reverse lookup. Another lookup is done on the resulting hostname and a list of all associated IP addresses is returned.

Passing an empty string “” returns a list of IP addresses assigned to the local computer

GetHostName none String Returns the name of the local computer

 

GetHostEntry Examples:

 

GetHostAddresses Examples:

 

GetHostName Example: