Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- //This will check the year today.
- DateTime year = DateTime.Now;
- if (DateTime.IsLeapYear(year.Year))
- {
- Console.WriteLine("{0} is leap", year.ToString("yyyy"));
- }
- else
- {
- Console.WriteLine("{0} is not leap", year.ToString("yyyy"));
- }
- //This will check any year you want
- Console.WriteLine("Enter a year:");
- short myYear = short.Parse(Console.ReadLine());
- if (myYear % 4 == 0 && myYear % 100 != 0 || myYear % 400 == 0)
- {
- Console.WriteLine("{0} is leap", myYear);
- }
- else
- {
- Console.WriteLine("{0} is not leap", myYear);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement