判断一年是否为闰年

        static void Main(string[] args)
        {
            while (true)
            { 
                Console.WriteLine("请输入您的年份");
                int x = Convert.ToInt32(Console.ReadLine());
                try
                {
                  DateTime y = Convert.ToDateTime(x+"-2-29");   //只要年份有2月29就是闰年
                  Console.WriteLine("是闰年");

                }
                catch (Exception)
                {
                    Console.WriteLine("不是闰年");
                  
                }
                Console.ReadLine();

posted @ 2015-04-02 19:31  XCml  阅读(131)  评论(0编辑  收藏  举报