using System.Collections.Generic;
private static string[] months = new [] { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC", "XXX" };
private static Dictionary<string,int> monthsDictionary = new Dictionary<string,int>();
public static void Main()
const int max = 10000000;
var random = new Random();
var start = DateTime.Now;
for(var count=0; count<max; count++) {
var index = random.Next(0,12);
var month = months[index];
var monthNumber = monthAbbreviationToInt(month);
Console.WriteLine(DateTime.Now.Subtract(start).Milliseconds);
for(var count=0; count<max; count++) {
var index = random.Next(0,11);
var month = months[index];
var monthNumber = getMonthNumber(month);
Console.WriteLine(DateTime.Now.Subtract(start).Milliseconds);
private static int monthAbbreviationToInt(string monthAbbreviation) {
switch (monthAbbreviation.ToLower()) {
private static int getMonthNumber(string monthAbbreviation) {
var key = monthAbbreviation;
if(monthsDictionary.ContainsKey(key)) {
return monthsDictionary[key];
private static void loadMonthsDictionary() {
for(var index=0; index < months.Length; index++) {
monthsDictionary[key] = index+1;