I bound my `private List<MaintenanceWindow> tempMaintenanceWindows` to a Datagrid and enabled the user to edit the items in the Datagrid as well as to add new items. This works fine.

Now I thought about how to rollback the changes the user made if the window is closed without pressing the save button first. Basically, I want to compare the Datagrid.ItemsSource to the temporary List I populated like this:

```
foreach (MaintenanceWindow mainWin in maintenanceWindowList)
                tempMaintenanceWindows.Add(new MaintenanceWindow {from = mainWin.from, to = mainWin.to, abbreviation = mainWin.abbreviation, description = mainWin.description, hosts = mainWin.hosts });

```

I compare the two like so:

```
if (!tempMaintenanceWindows.SequenceEqual((List<MaintenanceWindow>)mainWinList.ItemsSource))

```

but the result of the SequenceEqual always seems to be false, although when debugging the code, they seem to be the exact same thing.

Hope someone can help. Thanks.

---

Quentin Roger provided an approach solution which works but I want to post my code which is probably not the neatest way to do it but it fits to my case of application.

**So this is how I overrode the Equals method of my MaintenanceWindow object:**

```
public override bool Equals (object obj)
        {
            MaintenanceWindow item = obj as MaintenanceWindow;

            if (!item.from.Equals(this.from))
                return false;
            if (!item.to.Equals(this.to))
                return false;
            if (!item.description.Equals(this.description))
                return false;
            if (!item.abbreviation.Equals(this.abbreviation))
                return false;
            if (item.hosts != null)
            {
                if (!item.hosts.Equals(this.hosts))
                    return false;
            }
            else
            {
                if (this.hosts != null)
                    return false;
            }

            return true;
        }

```