Esempio n. 1
0
        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++;
            }
        }
Esempio n. 2
0
        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++;
            }
        }
Esempio n. 3
0
 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++;
     }
 }
Esempio n. 4
0
 public Enumerator(Phonebook pb)
 {
     this.pb = pb;
 }