Export (0) Print
Expand All

IPEndPoint.ToString Method

Returns the IP address and port number of the specified endpoint.

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

public:
virtual String^ ToString () override
public String ToString ()
public override function ToString () : String

Return Value

A string containing the IP address and the port number of the specified endpoint (for example, 192.168.1.2:23).

The following example returns a string representation of the IP address and port number of the specified IPEndPoint.

void displayEndpointInfo( IPEndPoint^ endpoint )
{
   Console::WriteLine( "Endpoint->Address : {0}", endpoint->Address );
   Console::WriteLine( "Endpoint->AddressFamily : {0}", endpoint->AddressFamily );
   Console::WriteLine( "Endpoint->Port : {0}", endpoint->Port );
   Console::WriteLine( "Endpoint.ToString() : {0}", endpoint );
   Console::WriteLine( "Press any key to continue." );
   Console::ReadLine();
}

private static void DisplayEndpointInfo(IPEndPoint endpoint)
{
    Console.WriteLine(("Endpoint.Address : " + endpoint.get_Address()));
    Console.WriteLine(("Endpoint.AddressFamily : " 
        + endpoint.get_AddressFamily()));
    Console.WriteLine(("Endpoint.Port : " + endpoint.get_Port()));
    Console.WriteLine(("Endpoint.ToString() : " 
        + endpoint.ToString()));
    Console.WriteLine("Press any key to continue.");
    Console.ReadLine();
} //DisplayEndpointInfo

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft