How To Easily Compare 2 Lists To Determine Differences

This will work with complex types too.

bool changesMade = ListOne.SequenceEqual(ListTwo);

Note this uses the default equality compare (Equals). You may need to override the equals.

 public override bool Equals(object obj)
            if (obj is JHAStaleNotification)
                JHAStaleNotification other = (JHAStaleNotification)obj;
                return (this.JHAStatus == other.JHAStatus && 
                    this.StaleUserType == other.StaleUserType &&
                    this.EntityStateType == other.EntityStateType &&
                    this.Frequency == other.Frequency &&
                    this.SendNotification == other.SendNotification &&
                    this.Threshold == other.Threshold);
                return false;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s