To do this, some people do this using resources and add it manually to the control (DropDownList, ListBox, etc...), but you can accomplish this by the following single line of code which returns the months names translated to the current Thread culture.
Thread.CurrentThread.CurrentCulture.DateTimeFormat.MonthNames.Take(12);
Demo:
If the current thread culture is “fr-FR” it returns:
If the current thread culture is “de-DE” it returns:
If the current thread culture is “ar-EG” it returns:
I hope that this saves some of your valuable time.
No comments:
Post a Comment