public void AddToEnd(contactInfo data) { if (headNode == null) { headNode = new Node(data); } else { headNode.AddToEnd(data); } }
public void AddToEnd(contactInfo data) { if (next == null) { next = new Node(data); } else { next.AddToEnd(data); } }
public static void askForContactInfo(MyList list) { ConsoleKeyInfo quitSentinel; do { // Get user input for contact information. Console.WriteLine("=========================="); Console.WriteLine("Please enter your contact information!\n"); Console.Write("Enter your first name: "); String firstName = Console.ReadLine(); Console.Write("Enter your last name: "); String lastName = Console.ReadLine(); Console.Write("Enter your address: "); String address = Console.ReadLine(); Console.Write("Enter your city: "); String city = Console.ReadLine(); Console.Write("Enter your state: "); String state = Console.ReadLine(); // Populate contactInfo data structure. contactInfo contacts = new contactInfo(firstName, lastName, address, city, state); // Add newly instantiated data structure to the back of the linked list. list.AddToEnd(contacts); Console.WriteLine("\nIf you would like to stop entering contact information, press the Escape button." + "\nOtherwise, press any button to continue."); quitSentinel = Console.ReadKey(); } while (quitSentinel.Key != ConsoleKey.Escape); Console.WriteLine("\n"); }
public Node(contactInfo i) { data = i; next = null; }