Dns.GetHostName Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the host name of the local computer.

Namespace:   System.Net
Assembly:  System (in System.dll)

static member GetHostName : unit -> string

Return Value

Type: System.String

A string that contains the DNS host name of the local computer.

Exception Condition

An error is encountered when resolving the local host name.

The following example uses the GetHostName method to obtain the host name of the local computer.

No code example is currently available or this language may not be supported.


for accessing DNS information. Associated enumeration: PermissionState.Unrestricted

.NET Framework
Available since 1.1
Return to top