internal bool Equals(object comparandObj, bool compareScopeId)
{
IPAddress comparand = comparandObj as IPAddress;
if (comparand == null)
{
return false;
}
// Compare families before address representations
if (AddressFamily != comparand.AddressFamily)
{
return false;
}
if (IsIPv6)
{
// For IPv6 addresses, we must compare the full 128-bit representation.
for (int i = 0; i < NumberOfLabels; i++)
{
if (comparand._numbers[i] != _numbers[i])
{
return false;
}
}
// The scope IDs must also match
return comparand.PrivateScopeId == PrivateScopeId || !compareScopeId;
}
else
{
// For IPv4 addresses, compare the integer representation.
return comparand.PrivateAddress == PrivateAddress;
}
}