I always thought that C# structs being value types meant that a comparison would be something like checking two blocks of memory are the same, but I just read https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type#struct-example and realized I'm mistaken.
For structs, the default implementation of Object.Equals(Object) (which is the overridden version in System.ValueType) performs a value equality check by using reflection to compare the values of every field in the type. When an implementer overrides the virtual Equals method in a struct, the purpose is to provide a more efficient means of performing the value equality check and optionally to base the comparison on some subset of the struct's fields or properties.
What is the reason the default Equals implementation of a C# struct needs to use field by field reflection as opposed to a straight value comparison of their data?
Consider structs that have members that are class-types and have overriden their Equals methods. For example:
Without reflection, the above would not work.