public void Init(List <pd_MailInfo> mail_list) { IsInit = true; if (Mails.Count > 0) { List <Mail> noexist = new List <Mail>(); foreach (var mail in Mails) { if (mail_list.Exists(m => m.mail_idx == mail.MailIdx) == false) { noexist.Add(mail); } } if (noexist.Count > 0) { noexist.ForEach(i => Mails.Remove(i)); } } foreach (var info in mail_list) { int index = Mails.FindIndex(mail => mail.MailIdx == info.mail_idx); if (index >= 0) { Mails[index].Data = info; } else { Mails.Add(new Mail(info)); } } OrderMailData(); }