标签:break || 括号 lse 知识 day adk line catch
static void Main(string[] args) switch (month)
{ //1,3,5,7,8,10,12 为31天;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31;
break;
//2月有润年之分,排除2月;
case 2:
if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
{
day = 29;
}
else
{
day = 28;
}
break;
//剩下的2,4,6,9,11为30天;
default:
day = 30;
break;
}
//输出该月的天数;
Console.WriteLine("{0}年{1}月的实际天数是{2}", year, month, day);
}
else
{
Console.WriteLine("输入的年份不正确,请重新输入");
}
}//这个括号跟catch跟月份的try配对
catch
{
Console.WriteLine("输入的月份不正确,请重新输入");
}
}//这个括号跟catch跟年份的try配对
catch
{
Console.WriteLine("输入的年份不正确,请重新输入");
}
Console.ReadKey();
}
标签:break || 括号 lse 知识 day adk line catch
原文地址:https://blog.51cto.com/12679593/2381724