private void PopulateEmailList(Contact newContact)
        {
            bool isNoMoreEmails = false;
            do
            {
                //make do while loop to continue adding phones to phones list
                Email newEmail = new Email();
                string userInput;

                Console.Write("What sort of email account is this? \n(work, personal, etc... or hit 'X' to move on): ");
                userInput = Console.ReadLine();
                Console.Clear();
                if (userInput.ToUpper() == "X")
                {
                    isNoMoreEmails = true;
                    Console.Clear();

                }
                else
                {
                    newEmail.EmailType = userInput;

                    Console.Write("Enter {1}'s {0} email: ", newEmail.EmailType, newContact.FirstName);
                    newEmail.EmailAddress = Console.ReadLine();

                    newContact.Emails.Add(newEmail);
                }

            } while (!isNoMoreEmails);
        }
Beispiel #2
0
        public List<Email> LoadEmailList(string emailList)
        {
            List<Email> allEmails = new List<Email>();
            string[] emails = emailList.Split('%');

            foreach (string e in emails)
            {
                if (e.Length > 0) //put in to combat last % yielding empty string
                {
                    string[] oneEmail = e.Split('^');

                    Email anEmail = new Email();
                    anEmail.EmailType = oneEmail[0];
                    anEmail.EmailAddress = oneEmail[1];//null ref using '1', changed to 0 - and back
                    allEmails.Add(anEmail);
                }
            }
            return allEmails;
        }