How to convert the Month Number to Month Name in C#

The following code will help if you have a need to convert the month number such as 3 to the month name like March.


//the following line of code will convert the month number to month name
string sMonthName = DateTime.Today.ToString(“MMM”);

// the following line of code will give you the Month Name and the Year
this.btnOne.Content = sFirstMonth + “-” + DateTime.Today.Year.ToString();


See the video below to see the working of the code live.