I have two clients that create IPAddress
instances from the same byte[]
and send it to the server over WCF (using DataContractSerializer
).
On the server, these IPAddress
instances are inserted as keys in a dictionary but for some reason they're added as different keys.
When logging I see that they're equal but GetHashCode
returns different results.
var client1Address = // sent from client1
var client2Address = // sent from client2
Console.WriteLine(client1Address.Equals(client2Address));
Console.WriteLine(client1Address.GetHashCode().Equals(client2Address.GetHashCode()));
Output:
true
false
How can equal IPAddress
instances return different GetHashCode
results?