/** * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful. */ public bool equals(DataPdu rhs) { bool ivarsEqual = true; if (rhs.GetType() != this.GetType()) { return(false); } if (!(_requestID == rhs._requestID)) { ivarsEqual = false; } if (!(_padding1 == rhs._padding1)) { ivarsEqual = false; } if (!(_numberOfFixedDatumRecords == rhs._numberOfFixedDatumRecords)) { ivarsEqual = false; } if (!(_numberOfVariableDatumRecords == rhs._numberOfVariableDatumRecords)) { ivarsEqual = false; } for (int idx = 0; idx < _fixedDatums.Count; idx++) { FixedDatum x = (FixedDatum)_fixedDatums[idx]; if (!(_fixedDatums[idx].Equals(rhs._fixedDatums[idx]))) { ivarsEqual = false; } } for (int idx = 0; idx < _variableDatums.Count; idx++) { VariableDatum x = (VariableDatum)_variableDatums[idx]; if (!(_variableDatums[idx].Equals(rhs._variableDatums[idx]))) { ivarsEqual = false; } } return(ivarsEqual); }
/** * Compares for reference equality and value equality. */ public bool equals(DataPdu rhs) { bool ivarsEqual = true; if(rhs.GetType() != this.GetType()) return false; ivarsEqual = base.Equals(rhs); if( ! (_requestID == rhs._requestID)) ivarsEqual = false; if( ! (_padding1 == rhs._padding1)) ivarsEqual = false; if( ! (_numberOfFixedDatumRecords == rhs._numberOfFixedDatumRecords)) ivarsEqual = false; if( ! (_numberOfVariableDatumRecords == rhs._numberOfVariableDatumRecords)) ivarsEqual = false; if( ! (_fixedDatums.Count == rhs._fixedDatums.Count)) ivarsEqual = false; if(ivarsEqual) { for(int idx = 0; idx < _fixedDatums.Count; idx++) { if( ! ( _fixedDatums[idx].Equals(rhs._fixedDatums[idx]))) ivarsEqual = false; } } if( ! (_variableDatums.Count == rhs._variableDatums.Count)) ivarsEqual = false; if(ivarsEqual) { for(int idx = 0; idx < _variableDatums.Count; idx++) { if( ! ( _variableDatums[idx].Equals(rhs._variableDatums[idx]))) ivarsEqual = false; } } return ivarsEqual; }