當GetHashCode()
函數返回使用代碼的代碼時它有一些特殊含義嗎?contains^symbol
?GetHashCode()with^
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();
}
}
許多答案指出,這不是XOR算子。它在這裏用來創建一個組合的哈希碼。看看這篇文章在這裏:http://stackoverflow.com/questions/1079192/is-it-possible-to-combine-hash-codes-for-private-members-to-generate-a-new- hash –