Partilhar via


IPEndPoint.ToString Método

Definição

Retorna o número da porta e endereço IP do ponto de extremidade especificado.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Retornos

Uma cadeia de caracteres que contém o endereço IP e o número da porta do ponto de extremidade especificado (por exemplo, 192.168.1.2:80).

Exemplos

O exemplo a seguir retorna uma representação de cadeia de caracteres do endereço IP e do número da porta do especificado 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.Address);
  Console.WriteLine("Endpoint.AddressFamily : " + endpoint.AddressFamily);
  Console.WriteLine("Endpoint.Port : " + endpoint.Port);
  Console.WriteLine("Endpoint.ToString() : " + endpoint.ToString());

  Console.WriteLine("Press any key to continue.");
  Console.ReadLine();
}
Private Shared Sub displayEndpointInfo(ByVal endpoint As IPEndPoint)
  Console.WriteLine("Endpoint Address : " + endpoint.Address.ToString())
  Console.WriteLine("Endpoint AddressFamily : " + endpoint.AddressFamily.ToString())
  Console.WriteLine("Endpoint Port : " + endpoint.Port.ToString())
  Console.WriteLine("Endpoint ToString() : " + endpoint.ToString())

  Console.WriteLine("Press any key to continue.")
  Console.ReadLine()
End Sub

Aplica-se a