Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
IPAddress Class
 IPAddress Members

  Switch on low bandwidth view
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
IPAddress Members

Provides an Internet Protocol (IP) address.

The IPAddress type exposes the following members.

  NameDescription
Public methodSupported by the .NET Compact FrameworkIPAddressOverloaded. Initializes a new instance of the IPAddress class.
Top
  NameDescription
Public methodSupported by the .NET Compact FrameworkEquals Compares two IP addresses. (Overrides Object..::.Equals(Object).)
Protected methodSupported by the .NET Compact FrameworkFinalize Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the .NET Compact FrameworkGetAddressBytes Provides a copy of the IPAddress as an array of bytes.
Public methodSupported by the .NET Compact FrameworkGetHashCode Returns a hash value for an IP address. (Overrides Object..::.GetHashCode()()().)
Public methodSupported by the .NET Compact FrameworkGetType Gets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberSupported by the .NET Compact FrameworkHostToNetworkOrderOverloaded. Converts a value from host byte order to network byte order.
Public methodStatic memberSupported by the .NET Compact FrameworkIsLoopback Indicates whether the specified IP address is the loopback address.
Protected methodSupported by the .NET Compact FrameworkMemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberSupported by the .NET Compact FrameworkNetworkToHostOrderOverloaded. Converts a number from network byte order to host byte order.
Public methodStatic memberSupported by the .NET Compact FrameworkParse Converts an IP address string to an IPAddress instance.
Public methodSupported by the .NET Compact FrameworkToString Converts an Internet address to its standard notation. (Overrides Object..::.ToString()()().)
Public methodStatic memberTryParse Determines whether a string is a valid IP address.
Top
  NameDescription
Public fieldStatic memberSupported by the .NET Compact FrameworkAny Provides an IP address that indicates that the server must listen for client activity on all network interfaces. This field is read-only.
Public fieldStatic memberSupported by the .NET Compact FrameworkBroadcast Provides the IP broadcast address. This field is read-only.
Public fieldStatic memberSupported by the .NET Compact FrameworkIPv6Any The Socket..::.Bind method uses the IPv6Any field to indicate that a Socket must listen for client activity on all network interfaces.
Public fieldStatic memberSupported by the .NET Compact FrameworkIPv6Loopback Provides the IP loopback address. This property is read-only.
Public fieldStatic memberSupported by the .NET Compact FrameworkIPv6None Provides an IP address that indicates that no network interface should be used. This property is read-only.
Public fieldStatic memberSupported by the .NET Compact FrameworkLoopback Provides the IP loopback address. This field is read-only.
Public fieldStatic memberSupported by the .NET Compact FrameworkNone Provides an IP address that indicates that no network interface should be used. This field is read-only.
Top
  NameDescription
Public propertySupported by the .NET Compact FrameworkAddress Obsolete. An Internet Protocol (IP) address.
Public propertySupported by the .NET Compact FrameworkAddressFamily Gets the address family of the IP address.
Public propertyIsIPv6LinkLocal Gets whether the address is an IPv6 link local address.
Public propertyIsIPv6Multicast Gets whether the address is an IPv6 multicast global address.
Public propertyIsIPv6SiteLocal Gets whether the address is an IPv6 site local address.
Public propertySupported by the .NET Compact FrameworkScopeId Gets or sets the IPv6 address scope identifier.
Top
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
How to copy an IPAddress?      Ryan Melville   |   Edit   |   Show History

How can one copy an IPAddress? There doesn't seemt to be a copy constructor or assignment operator or public Copy() member of any kind.

Does one really have to use IPAddress::GetAddressBytes() like this (C++/CLI):

IPAddress^ orig = gcnew IPAddress(IPAddress::None);

IPAddress^ copy = gcnew IPAddress(orig->GetAddressBytes());

That seems rather obtuse. Is there a more obvious/elegant way? Should there be?

[ADDITION]

And, now that I notice the "ScopeId" property, it doesn't seem that the above snippet even works. One must be sure to grab that as well:

IPAddress^ copy = gcnew IPAddress(orig->GetAddressBytes(), orig->ScopeId);

That seems even less elegant. And also out-right wrong if/when any other properties are added to the class in the future. Hence the reason classes should encapsulate their own copy symantecs, I would think.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker