Partager via


IPAddress.IPv6Loopback Field

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Provides the IP loopback address. This property is read-only.

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

Syntax

'Declaration
Public Shared ReadOnly IPv6Loopback As IPAddress
public static readonly IPAddress IPv6Loopback

Remarks

The IPv6Loopback field is equivalent to 0:0:0:0:0:0:0:1 in colon-hexadecimal notation, or to ::1 in compact notation.

The IPv6Loopback field is defined even when the Socket.OSSupportsIPv6 property is false.

Examples

The following code example displays the value of the current host's IPv6 loopback address.

' This sample prints the value of the current host loopback address in  
' standard compressed format. 
   Try
      ' Get the loopback address.
      Dim loopBack As IPAddress = IPAddress.IPv6Loopback

      ' Transform the loop-back address to a string using the overloaded
      ' ToString() method. Note that the resulting string is in the compact 
      ' form: "::1".
      Dim ipv6LoopBack As String = loopBack.ToString()
      outputBlock.Text &= "The IPv6 Loopback address is: "
      outputBlock.Text &= ipv6LoopBack
      outputBlock.Text &= vbCrLf
   Catch e As Exception
      outputBlock.Text &= "Exception: "
      outputBlock.Text &= e.ToString()
      outputBlock.Text &= vbCrLf
   End Try
// This method displays the value of the current host loopback address in  
// standard compressed format. 
    try
    { 
      // Get the loopback address.
      IPAddress loopBack = IPAddress.IPv6Loopback;

      // Transform the loop-back address to a string using the overladed
      // ToString() method. Note that the resulting string is in the compact 
      // form: "::1".
      string ipv6LoopBack = loopBack.ToString();

      outputBlock.Text += "The IPv6 Loopback address is: ";
      outputBlock.Text += ipv6LoopBack;
      outputBlock.Text += "\n";

    }
    catch (Exception e) 
    {
      outputBlock.Text += "Exception: ";
      outputBlock.Text += e.ToString();
      outputBlock.Text += "\n";
    }

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.