Class IPAddressComparer
Provides the order of IP addresses that Compare(IPAddress?, IPAddress?) gives.
public class IPAddressComparer : IComparer<IPAddress>
- Inheritance
-
IPAddressComparer
- Implements
- Inherited Members
Remarks
A null comes first; an IPv4-mapped IPv6 address counts as its IPv4 address; IPv4 addresses come before IPv6 ones; and addresses compare by their bytes, without scope IDs, so two IPv6 addresses of different scopes can compare equal.
Methods
Compare(IPAddress?, IPAddress?)
Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
public int Compare(IPAddress? x, IPAddress? y)
Parameters
Returns
- int
A signed integer that indicates the relative values of
xandy, as shown in the following table.Value Meaning Less than zero xis less thany.Zero xequalsy.Greater than zero xis greater thany.