I have piece metaled this code together from multiple google searches and thanks to the function from the site mentioned in the code. I am sure there are ways to optimize this for speed. What do you guys suggest?
using System;
using System.Globalization;
public class Program
{
public static void Main()
{
string shortmonth = "Mar";
string num = GetMonthNumberFromAbbreviation(shortmonth);
string monthname = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(num));
Console.WriteLine(monthname);
}
//https://blogs.msmvps.com/deborahk/converting-month-abbreviations-to-month-numbers/
private static string GetMonthNumberFromAbbreviation(string mmm)
{
string[] monthAbbrev =
CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedMonthNames;
int index = Array.IndexOf(monthAbbrev, mmm) + 1;
return index.ToString("0#");
}
}