Liệu nó có một số ý nghĩa đặc biệt khi hàm GetHashCode()
trả về nội dung nào đó sử dụng mã số contains^symbol
?GetHashCode() với^
public class ClassProp
{
public int Prop1 { get; set; }
public int Prop2 { get; set; }
public int Prop3 { get; set; }
public int Prop4 { get; set; }
public int Prop5 { get; set; }
public override int GetHashCode()
{
return Prop1.GetHashCode()^Prop2.GetHashCode()^
Prop3.GetHashCode()^Prop4.GetHashCode()^Prop5.GetHashCode();
}
}
Nhiều câu trả lời cho rằng đó không phải là toán tử XOR. Nó được sử dụng ở đây chỉ để tạo ra một hashcode kết hợp. Hãy xem bài đăng này tại đây trên SO: http://stackoverflow.com/questions/1079192/is-it-possible-to-combine-hash-codes-for-private-members-to-generate-a-new- hash –