I feel bad asking this question but I am currently not able to program and test this as I’m writing this on my cell-phone and not on my dev machine 😛 (Easy rep points if someone answers! XD )
Anyway, I’ve had experience with using hashvalues from String objects. E.g., if I have StringA and StringB both equal to “foo”, they’ll both compute out the same hashvalue, because they’re set to equal values.
Now what if I have a List, with T being a native data type. If I tried to compute the hashvalue of ListA and ListB, assuming that they’d both be the same size and contain the same information, wouldn’t they have equal hashvalues as well?
Assuming as sample dataset of ‘byte’ with a length of 5
{5,2,0,1,3}
If your talking about the built-in list types, then no, they will not be equal. Why? Because
List<T>is a reference type, so equality will do a comparison to see if the references are the same. If you are creating a custom list type, then you could override theEqualsandGetHashCodemethods to support this behavior, but it isn’t going to happen on the built in types.