码迷,mamicode.com
首页 > 其他好文 > 详细

判断年份

时间:2015-04-03 09:08:32      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!