I have a list of Months displayed in a drop down. On selecting a particular month I would like to display the number of the month in a text box.
For example if I select January I would like to display it as 01, likewise for the others.
This is the sample code I have written:
string monthName = "january";
int i = DateTime.ParseExact(monthName, "MMMM", CultureInfo.CurrentCulture).Month;
Use this code to convert the selected Month Name into a Month Number
Need String Padding?
References
Sample Console Application