//initialize the datetime object with today's date
DateTime todaysDate = DateTime.Now;
//get the current culture
CultureInfo properCase = System.Threading.Thread.CurrentThread.CurrentCulture;
//get text info object from the current culture
TextInfo textInfoObject = properCase.TextInfo;
//the textinfo ToTitleCase method will return the text in title case
MessageBox.Show(textInfoObject.ToTitleCase(todaysDate.ToString("MMMM")));
Output:
October
Here, the todaysDate.ToString("MMMM") prints the complete month like October, December etc.
No comments:
Post a Comment