Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
- using System.Threading.Tasks;
- namespace PhoneBookExample
- {
- class Program
- {
- public static List<string> PhoneBookPrev = new List<string>();
- String[] PhoneBook = PhoneBookPrev.ToArray();
- static void Main(string[] args)
- {
- string Input;
- Console.Title = "PhoneBookV1";
- while (true)
- {
- Console.WriteLine("Get or Set?");
- Input = Console.ReadLine();
- if (Input == "Get")
- {
- Get();
- }
- else if (Input == "Set")
- {
- Set();
- }
- else
- {
- Console.WriteLine("Invalid Decision.");
- }
- }
- }
- public static void Get()
- {
- Console.Clear();
- Console.WriteLine("-----------------------------------------------");
- Console.WriteLine("Getting All Contacts... Please be Patient.");
- Console.WriteLine("-----------------------------------------------");
- System.Threading.Thread.Sleep(5000);
- Console.Clear();
- if (PhoneBookPrev.Count <= 0)
- {
- Console.WriteLine("No Contacts Found.");
- System.Threading.Thread.Sleep(5000);
- Console.Clear();
- }
- else if (PhoneBookPrev.Count > 0)
- {
- Console.WriteLine("A Total of " + PhoneBookPrev.Count + " Contacts were Found.");
- Console.WriteLine("-------------------------------------------------------------------");
- foreach (string contactInfo in PhoneBookPrev)
- {
- Console.WriteLine(contactInfo);
- }
- Console.WriteLine("-------------------------------------------------------------------");
- }
- }
- public static void Set()
- {
- string info;
- Console.WriteLine("-- Set a new PhoneBook --");
- Console.WriteLine();
- Console.Write("Enter Name: ");
- info = Console.ReadLine();
- try
- {
- PhoneBookPrev.Add(info);
- Console.Write("Contact " + info + " has been successfully added to your contacts.");
- }
- catch (Exception)
- {
- Console.Write("There was an Error whilst trying to add that Contact Information!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement