using System.Collections.Generic;
public string str { get; set; }
public DateTime date { get; set; }
class totoComparer : IEqualityComparer<toto>
public bool Equals(toto b1, toto b2)
if (b2 == null && b1 == null)
else if (b1 == null || b2 == null)
else if (b1.str == b2.str && b1.date == b2.date)
public int GetHashCode(toto t)
hash = (hash * 7) + t.str.GetHashCode();
hash = (hash * 7) + t.date.GetHashCode();
public static void Main()
var @old = new List<toto> {
new toto{ str= "EXist", date= DateTime.Today },
new toto{ str= "NotExist", date= DateTime.Today },
new toto{ str= "ExistButOld", date= DateTime.Today },
var @new = new List<toto> {
new toto{ str= "EXist", date= DateTime.Today },
new toto{ str= "NotExist2", date= DateTime.Today },
new toto{ str= "ExistButOld", date= DateTime.Today.AddDays(2) }
var created = @new.Except(@old, new totoComparer()).ToList();
var deleted = @old.Except(@new, new totoComparer()).ToList();
Console.WriteLine("\ncreated");
Console.WriteLine("\ndeleted");