Tuesday, January 3, 2012

Java/C# program to display the number of days in a particular month?

Well unless there are specific restrictions for you not to use the DateTime cl to help you do this... you can try using DateTime.DaysInMonth (doc source below) but you also need the year, like you said, because of leap years. You could get the year from the current year and just ask the user for the month. If you can't use DaysInMonth then google the calculation for leap years, that would be the correct way to do it.

No comments:

Post a Comment