.NET Array Expectations
While creating a mini C# code generator, I discovered that .NET Arrays don’t behave the way I expected with respect to the Equals and GetHashCode implementations. The expectation wasn’t based on any documentation, just what would be expected from a consistency point of view. I expected to be able to compare two different array instances (of bytes in this case) to see if their value contents were the same. Similarly I expected arrays with the same size and values to return equivalent GetHashCode values. It looks like the Array Equals and GetHashCode methods are actually just the default System.Object methods. There’s probably good reason for this (probably performance related), but unfortunately there isn’t time to look into it in more detail at the moment. All the fundamentals of a framework such as .NET can be simple in concept, but not easy to fully comprehend. I’m not explaining myself well here, but concepts such as identity and equivalence are deceptive with respect to their simplicity.