我想将MyPacket类型的变量传递给handleMessage,它会给出错误。
public override bool Equals(object obj) { if (obj.GetType() != typeof(CompareClass)) return false; if (this.compare1 == ((CompareClass)obj).compare1 && this.compare2 == ((CompareClass)obj).compare2) return true ; else return false; } // oversimplified, this link is more appropriate // http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode public override int GetHashCode() { return (this.compare1.GetHashCode() + this.compare2.GetHashCode()) * 11 + 2; }
答案 0 :(得分:2)
您的MyPacket
将转换为C {{{{{{{{{{{{}} {{}}。 MyPacket
继承自cPacket
,因此会由cPacket
处理。但是,在cMessage
中,您必须识别并投射数据包,例如:
handleMessage