Mono Class Library: System.Net.SocketAddress Overview | Members

System.Net.SocketAddress.ToString Method

Returns a string representation of the value of the current instance.

public override string ToString ()

Returns

A string representation of the current instance.

Remarks

The returned string contains the string representation of the address family, the length of the array holding the socket address, and the contents of the array from the third to the maximum element, output in the following format:

SocketAddress.Family:SocketAddress.Size:{array[2], array[3], ..., element[Size- 1]}

Note:

This method overrides object.ToString.

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