How many months are there in a year ?
Silly question, but interesting if you are writing a program and you want to return the months based on the culture of the user.
Instead of having to hand code all the month names all you have to do is write the following piece of code:
string
[] _monthNames = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames;so question is what is the length of _monthNames ?
You would expect 12 as there are normally 12 months in the year, but you would be wrong it is 13 !!
_monthNames[12] returns a blank string.
This is great if you are simply using _monthNames as a look for the names of the month but a bit of pain if you use it as the data source of a combo box.
I assume there must be cultures out there which have 13 months but why isn't the return string array dimensioned based on the current culture ?