.NET Standard 2.1 / .NET Core 3 introduce System.HashCode
to quickly combine fields and values to a hash code without having to care about the underlying implementation.
However, it only provides Combine
method overloads for up to 8 values. What do I do if I have a class with 9 values (3x3 matrix) or even 16 values (4x4 matrix)?
Should I simply add together the results of two Combine
calls, passing as many values as possible in each?
public override int GetHashCode()
=> HashCode.Combine(M11, M12, M13, M21, M22, M23, M31, M32) + HashCode.Combine(M33);
Looking at the source, I cannot completely argue if this may have implications I don't know of.