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;
}
}
}
}
}
C#之十 一 迷你电话博
最新推荐文章于 2023-03-30 22:06:55 发布