This documentation is archived and is not being maintained.

IPAddress.AddressFamily Property

Gets the address family of the IP address.

[Visual Basic]
Public ReadOnly Property AddressFamily As AddressFamily
[C#]
public AddressFamily AddressFamily {get;}
[C++]
public: __property AddressFamily get_AddressFamily();
[JScript]
public function get AddressFamily() : AddressFamily;

Property Value

Returns AddressFamily.InterNetwork in for IPv4 or AddressFamily.InterNetworkV6 for IPv6.

Example

[Visual Basic, C#, C++] Refer to the example in the IPAddress class topic.

[Visual Basic] 
' Display the type of address family supported by the server. If the
' server is IPv6-enabled this value is: InternNetworkV6. If the server
' is also IPv4-enabled there will be an additional value of InterNetwork.
Console.WriteLine(("AddressFamily: " + curAdd.AddressFamily.ToString()))

' Display the ScopeId property in case of IPV6 addresses.
If curAdd.AddressFamily.ToString() = ProtocolFamily.InterNetworkV6.ToString() Then
  Console.WriteLine(("Scope Id: " + curAdd.ScopeId.ToString()))
End If

[C#] 

          // Display the type of address family supported by the server. If the
          // server is IPv6-enabled this value is: InternNetworkV6. If the server
          // is also IPv4-enabled there will be an additional value of InterNetwork.
          Console.WriteLine("AddressFamily: " + curAdd.AddressFamily.ToString());
          
          // Display the ScopeId property in case of IPV6 addresses.
          if(curAdd.AddressFamily.ToString() == ProtocolFamily.InterNetworkV6.ToString())
            Console.WriteLine("Scope Id: " + curAdd.ScopeId.ToString());


[C++] 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

IPAddress Class | IPAddress Members | System.Net Namespace

Show: