xor'ing hashcodes doesn't guarantee uniqueness, but is usually used to improve the distribution over a table without complicating the hashing.
You want to make 2 different values map to different hash keys if they differ in any of the fields (i.e. - same ModelType
, but different Perspective
, or vice versa). So you need to incorporate both values into your hash key. You could have used +
for example, or shift and concatenate them (the latter would be better in fact, as it would guarantee uniqueness, but also extend the key length which might complicate hashing).
xor won't guarantee this uniqueness since if you flip the same bit in ModelType
and Perspective
, you'd get the same hash key, for example 5 ^ 7 = 1 ^ 3 = 2, but it's usually good enough. Eventually it all depends on the ranges and distributions of the values you provide.