Q:

Write a C# Sharp program to get the number of days of the specified month and year

0

Write a C# Sharp program to get the number of days of the specified month and year. 

Expected Output:

31                                                                               
28                                                                               
29  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
public class Example19
{
	static void Main()
	{
		const int July = 7;
		const int Feb = 2;

		int daysInJuly = System.DateTime.DaysInMonth(2016, July);
        Console.WriteLine(daysInJuly);

		// 2013 was not a leap year.
		int daysInFeb = System.DateTime.DaysInMonth(2013, Feb);
        Console.WriteLine(daysInFeb);

		// 2004 was a leap year.
		int daysInFebLeap = System.DateTime.DaysInMonth(2004, Feb);
		Console.WriteLine(daysInFebLeap);
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now