public static int GetErrorCode(string errorName) { int value; if (!ErrorNameMap.TryGetValue(errorName, out value)) throw new InvalidOperationException(String.Format("Error '{0}' was not defined.", errorName)); return value; }