For all of those properties, just use ==
instead of calling Equals
:
return OutTravelType == other.OutTravelType &&
BackTravelType == other.BackTravelType &&
...;
All of those types are either handled directly (int, bool, enum) or have overloaded ==
operators (string
). Note the use of &&
instead of &
, as &&
is short-circuiting: there's no point in checking the other 10 properties if the first one compares non-equal.
As an aside, it looks like you could encapsulate all the "Out" properties together and all the "Back" properties together, leaving you with just:
return OutwardJourney == other.OutwardJourney &&
ReturnJourney == other.ReturnJourney &&
Checkin == other.Checkin; // Looks like this isn't part of out/back
where a Journey
would have a travel type, travel point ID, terminal, time and "free" (whatever that means).