コード例 #1
0
    static void Main(string[] args)
    {
        Console.Title = "Leap year";

        Console.ForegroundColor = ConsoleColor.Green;
        Console.Write("Enter an year: ");

        DateTime date = new DateTime(int.Parse(Console.ReadLine()), 1, 1);

        LeapYear leapYear = new LeapYear(date);

        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine("\nIs the year {0} is leap ?", leapYear.Year); // Calling the property and get the year
        Console.WriteLine("---> Answer: {0} <---", leapYear.IsLeap()); // Calling the method and check the year

        // Embedded method to check the result
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("\n===> Answer: {0} <=== Embedded method for check", DateTime.IsLeapYear(leapYear.Year));
 
        Console.WriteLine();
        Console.ResetColor();
    }
コード例 #2
0
    static void Main(string[] args)
    {
        Console.Title = "Leap year";

        Console.ForegroundColor = ConsoleColor.Green;
        Console.Write("Enter an year: ");

        DateTime date = new DateTime(int.Parse(Console.ReadLine()), 1, 1);

        LeapYear leapYear = new LeapYear(date);

        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine("\nIs the year {0} is leap ?", leapYear.Year); // Calling the property and get the year
        Console.WriteLine("---> Answer: {0} <---", leapYear.IsLeap());   // Calling the method and check the year

        // Embedded method to check the result
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("\n===> Answer: {0} <=== Embedded method for check", DateTime.IsLeapYear(leapYear.Year));

        Console.WriteLine();
        Console.ResetColor();
    }