标签:
while (true)
{
Console.Write("请输入一个年份:");
string a = Console.ReadLine();
string b = "";
try
{
DateTime c = Convert.ToDateTime(a+"-2-29");
b="年是闰年";
}
catch (Exception)
{
b = "年不是闰年";
}
finally
{
Console .WriteLine (a+b);
}
// Console.Write("请输入一个年份:");
//int a = Convert.ToInt32(Console .ReadLine ());
//if (a%400==0||a%4==0&&a%100!=0)
//{
// Console.WriteLine(a+"为闰年");
//}
//else
//{
// Console.WriteLine(a+"为平年");
//}
}
标签:
原文地址:http://www.cnblogs.com/Mr-xue/p/4389080.html