//7.輸入年月日,看看格式是否正確。利用DateTime。
//(1)
//DateTime dt=DateTime.Now;
//Console.Write("請輸入現在的年:");
//string n = Console.ReadLine();
//Console.Write("請輸入今天是幾月:");
//string y = Console.ReadLine();
//Console.Write("請輸入今天幾號:");
//string r = Console.ReadLine();
//string m=n+"年"+y+"月"+r+"日";
//if (m == dt.ToLongDateString().ToString())
//{
// Console.WriteLine("您輸入的日期正確是今天");
// Console.WriteLine("今天的日期是:" + dt.ToLongDateString().ToString());
//}
//else
//{
// Console.WriteLine("您輸入的日期不正確不是今天");
// Console.WriteLine("今天的日期是:" + dt.ToLongDateString().ToString());
//}
//(2)
DateTime dt;
try
{
Console.Write("請輸入日期:(例如:2000-01-01 或 2000/01/01):");
dt = DateTime.Parse(Console.ReadLine());
Console.WriteLine("您輸入的格式正確,日期為:{0}年{1}月{2}日", dt.Year, dt.Month, dt.Day);
}
catch
{
Console.WriteLine("您輸入的格式不對");
}