Last active
December 15, 2015 03:29
-
-
Save yicone/5194704 to your computer and use it in GitHub Desktop.
这种情况,GetHaseCode该如何实现?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FlightsPlanEqualityComparer : IEqualityComparer<FlightsPlan> | |
{ | |
public bool Equals(FlightsPlan x, FlightsPlan y) | |
{ | |
if (x.Flights.Count != y.Flights.Count) | |
{ | |
return false; | |
} | |
for (int i = 0; i < x.Flights.Count; i++) | |
{ | |
var fx = x.Flights[i]; | |
var fy = y.Flights[i]; | |
if (fx.FlightNo != fy.FlightNo || fx.FlightSeat != fy.FlightSeat) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
public int GetHashCode(FlightsPlan obj) | |
{ | |
// FardId是FlightsPlan的唯一标识 | |
//return obj.FareId.GetHashCode(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
return obj.FlightNo.GetHashCode()^obj.FlightSeat.GetHashCode()