Provides data for a hostname or an IP address.
The HostName class has these types of members:
The HostName class has these constructors.
|HostName||Creates a new HostName object from a string that contains a hostname or an IP address.|
The HostName class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
|Compare||Compares two strings to determine if they represent the same hostname.|
|IsEqual||Determines whether the specified HostName object has an equivalent value to the current HostName object.|
|ToString||Returns a string that represents the HostName object.|
The HostName class has these properties.
|Read-only||Gets the canonical name for the HostName object.|
|Read-only||Gets the display name for the HostName object.|
|Read-only||Gets the IPInformation object for a local IP address assigned to a HostName object.|
|Read-only||Gets the original string used to construct the HostName object.|
|Read-only||Gets the HostNameType of the HostName object.|
The HostName class is used to initialize and provide data for a hostname used in network apps. A HostName object can be used for a local hostname or a remote hostname used to establish a network connection.
The HostName object is used by many classes in other related namespaces for network apps. These include the following:
- Many classes in the Windows.Networking.Sockets namespace using sockets. Methods on the DatagramSocket and StreamSocket classes can be used to establish network connections and transfer data to a remote HostName object.
- The NetworkInformation class in the Windows.Networking.Connectivity namespace.
The following example creates a HostName and then tries to connect to the HostName using a StreamSocket.
Minimum supported client
|Windows 8 [Windows Store apps, desktop apps]|
Minimum supported server
|Windows Server 2012 [Windows Store apps, desktop apps]|
Minimum supported phone
|Windows Phone 8|