1. using System; 
  2.  
  3. namespace Leap_Year 
  4.     internal class Program 
  5.     { 
  6.         private static void Main(string[] args) 
  7.         { 
  8.             Console.WriteLine("       闰年判断         "); 
  9.             Console.WriteLine("************************"); 
  10.  
  11.             Console.WriteLine("请输入一个年份:"); 
  12.             try 
  13.             { 
  14.                 int year = int.Parse(Console.ReadLine()); 
  15.  
  16.                 if (LeapYear(year)) 
  17.                 { 
  18.                     Console.WriteLine("您输入的是一个闰年!"); 
  19.                 } 
  20.                 else 
  21.                 { 
  22.                     Console.WriteLine("您输入的是一个非闰年!"); 
  23.                 } 
  24.             } 
  25.             catch 
  26.             { 
  27.                 Console.WriteLine("您输入的不是一个正确的年份!"); 
  28.             } 
  29.             Console.ReadKey(); 
  30.         } 
  31.  
  32.         public static bool LeapYear(int year)   //定义一个方法来判断是否闰年 
  33.         { 
  34.             if (year % 4 == 0 || year % 400 == 0 && year % 100 != 0) 
  35.             { 
  36.                 return true
  37.             } 
  38.             else 
  39.             { 
  40.                 return false
  41.             } 
  42.         } 
  43.     }