GetHostName Method

Dns::GetHostName Method ()


Gets the host name of the local computer.

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

static String^ GetHostName()

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.

Legacy Code Example

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

   void DisplayAttributes( XmlReader^ reader )
      if ( reader->HasAttributes )
         Console::WriteLine( "Attributes of <{0}>", reader->Name );
         for ( int i = 0; i < reader->AttributeCount; i++ )
            reader->MoveToAttribute( i );
            Console::Write( " {0}={1}", reader->Name, reader->Value );

         reader->MoveToElement(); //Moves the reader back to the element node.

for accessing DNS information. Associated enumeration: PermissionState::Unrestricted

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft