static void Main(string[] args) { Person Person1 = new Person(); Contacts contact = new Contacts(); Person1.setfirst("Jack"); Person1.setlast("Gallacher"); Person1.setdob("29/04/1993"); Person1.setadd("Lincoln"); Person1.setno(11266257); contact.addcontact(Person1);//adds person to the array. Console.WriteLine(contact.mycontacts[0].firstname.ToString() + "\n");//looks into the array position and pull out the specific peice of data stored within that class in that position. Console.WriteLine(contact.mycontacts[0].lastname.ToString() + "\n"); Console.WriteLine(contact.mycontacts[0].dob.ToString() + "\n"); Console.WriteLine(contact.mycontacts[0].address.ToString() + "\n"); Console.WriteLine(contact.mycontacts[0].telno.ToString() + "\n"); Console.Read(); }
public void addcontact(Person myperson)//adds person to the array. { mycontacts[count] = myperson; count++; }