try判断是不是闰年try-catch

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string rn = Console.ReadLine();
                string s = "";
                try
                {
                    DateTime rn1 = Convert.ToDateTime(rn + "-2-29");系统自动判断,根据系统时间
                    s = "年是闰年";
                }
                catch (Exception)
                {
                    s = "年不是闰年";
                }
                finally
                {
                    Console.WriteLine(rn+s);
                }
            }
        }
    }
}

 

posted @ 2015-04-03 08:46  Yusarin  阅读(199)  评论(0编辑  收藏  举报