I have a class that contains the following two properties:
public int Id { get; private set; }
public T[] Values { get; private set; }
<
How about something like:
public override int GetHashCode()
{
int hash = Id;
if (Values != null)
{
hash = (hash * 17) + Values.Length;
foreach (T t in Values)
{
hash *= 17;
if (t != null) hash = hash + t.GetHashCode();
}
}
return hash;
}
This should be compatible with SequenceEqual
, rather than doing a reference comparison on the array.