//语法: public static bool IsLeapYear(int year) //用法举例: using System; public class IsLeapYear { public static void Main() { for (int year = 1994; year <= 2014; year++) { if (DateTime.IsLeapYear(year)) { Console.WriteLine("{0} is a leap year.", year); DateTime leapDay = new DateTime(year, 2, 29); DateTime nextYear = leapDay.AddYears(1); Console.WriteLine(" One year from {0} is {1}.", leapDay.ToString("d"),nextYear.ToString("d")); } } } }
时间: 2024-10-08 18:05:08