public void Insert(ref Phonebook pb, int index, string name, int number) { int i = 0; foreach (Phonebook item in pb) { if (i == index) { item.name = name; item.number = number; return; } i++; } }
public void RemoveAt(ref Phonebook pb, int index) { int i = 0; Phonebook _root = (Phonebook)pb.Clone(); foreach (Phonebook person in _root) { if (i == index) { pb = person.Next; return; } pb = pb.Next; i++; } }
public void Add(string name, int number) { if (Count == 0) { this.name = name; this.number = number; Count++; _last = this; } else { _last.Next = new Phonebook { name = name, number = number }; _last = _last.Next; Count++; } }
public Enumerator(Phonebook pb) { this.pb = pb; }