Use DateTime.IsLeapYear(year).
Write a program, which reads from the console a year and checks if it
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Use DateTime.IsLeapYear(year).
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Oct 20, 2023, 8:56 AM EDT
Hi Sara,
public static void Main() { Console.WriteLine("Enter Year : "); int year = int.Parse(Console.ReadLine()); // using method if (DateTime.IsLeapYear(year)) { Console.WriteLine("{0} is a Leap Year.", year); // do stuff } else { Console.WriteLine("{0} is not a Leap Year.", year); // do stuff } Console.ReadLine(); }