break语句

//输入年月,不正确重新输入
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();

posted @ 2016-03-11 15:52  万里冰封  阅读(179)  评论(0编辑  收藏  举报