C#之十 一 迷你電話博

using System;
using System.Collections;
namespace telbook
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "迷你電話博";
            ArrayList telArray = new ArrayList();//數組存放電話號碼
            while (true)
            {
                Console.Clear();
                Console.WriteLine("********迷你電話博*******");
                Console.WriteLine("*  歡迎使用迷你電話博   *");
                Console.WriteLine("*  請輸入操作鍵操作     *");
                Console.WriteLine(" a.新增, q.查詢, e.退出  ");

                string opration = Console.ReadLine().ToString();//數據轉換

                //新增
                if (opration == "a")
                {
                    Console.Write("請輸入姓名:");
                    string name = Console.ReadLine();
                    Console.Write("請輸入電話號碼:");
                    string tel = Console.ReadLine();
                    telArray.Add(new Person() { Name = name, Tel = tel });//??
                }

                //查詢 
                else if (opration == "q")
                {
                    Console.Clear();
                    Console.WriteLine("迷你電話博");
                    Console.WriteLine("姓名           電話");
                    foreach (object person in telArray)
                    {
                        Console.WriteLine("{0}         {1}", ((Person)person).Name, ((Person)person).Tel);//??
                    }
                    Console.ReadLine();
                }

            
                //退出程序
                else if (opration == "e")
                {

                    Console.Clear();
                    Console.WriteLine("歡迎再次使用,謝謝!!");
                    Console.ReadKey();
                    return;


                }
            }
        }
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章