//输入年月,不正确重新输入
for (; ; )
{
Console.WriteLine("输入年份:");
int year = int.Parse(Console.ReadLine());
if (year >= 0 && year <= 9999)
{
Console.WriteLine("今年是" + year);
for (; ; )
{
Console.Write("输入月份:");
int month = int.Parse(Console.ReadLine());
if (month >= 1 && month <= 12)
{
Console.WriteLine("月份是:" + month);
Console.ReadLine();
break;
}
else
Console.WriteLine("月份有误,重新输入:");
}
break;
}
else
Console.WriteLine("年份有误,重新输入:");
}
Console.ReadLine();