System.Net.SocketAddress.ToString Method

Returns information about the socket address.

Syntax

public override string ToString ()

Returns

A string that contains information about the System.Net.SocketAddress.

Remarks

The SocketAddress.ToString method returns a string that contains the System.Net.Sockets.AddressFamily enumerated value, the size of the underlying buffer of the System.Net.SocketAddress structure, and the remaining contents of the buffer.

Example

The following example writes a socket address to the console.

C# Example

using System;
using System.Net;
using System.Net.Sockets;

public class SocketAddressToString{
  public static void Main() {
    Console.WriteLine("This is a minimal SocketAddress.");
    SocketAddress socketAddress = new 
           SocketAddress(AddressFamily.InterNetwork);
    Console.WriteLine("{0}", socketAddress.ToString());
  }
}
   

The output is

This is a minimal SocketAddress.
InterNetwork:32:{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0