//实现增加联系人功能 public static void Add(string name, DateTime dayOfBirth, string phone) { Person person = new Person(); person.Name = String.IsNullOrEmpty(name) ? "未命名" : name; person.DayOfBirth = dayOfBirth; person.Phone = phone; ContactsBook.Contacts.Add(person); ContactsBook.Save(); }
//实现删除联系人功能 public static void Remove(int index) { ContactsBook.Contacts.RemoveAt(index); ContactsBook.Save(); }
static List <Person> _contacts; //存储联系人的列表 static ContactsBook() //静态构造 { _contacts = ContactsBook.Open(); }
//实现清空通讯录功能 public static void RemoveAll() { ContactsBook.Contacts.Clear(); ContactsBook.Save(); }