Table of Contents

Class IPAddressComparer

Namespace
VpnHood.Net.Toolkit.Net
Assembly
VpnHood.Net.Toolkit.dll

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

x IPAddress

The first object to compare.

y IPAddress

The second object to compare.

Returns

int

A signed integer that indicates the relative values of x and y, as shown in the following table.

Value Meaning
Less than zerox is less than y.
Zerox equals y.
Greater than zerox is greater than y.