Example #1
0
        public static States ParseState(string state)
        {
            // See if the abbreviation matches one of the states:
            States result = States.Unknown;

            if (AbbreviationAttribute.TryFindAbbreviation <States>(state, true, ref result))
            {
                return(result);
            }

            // Try to parse the full state name:
            try
            {
                return((States)Enum.Parse(typeof(States), state, true));
            }
            catch
            {
                // Couldn't parse the full state name!
                return(States.Unknown);
            }
        }
Example #2
0
 public static string GetStateAbbreviation(States state)
 {
     return(AbbreviationAttribute.GetAbbrevation(state));
 }
Example #3
0
 public static string GetStateAbbreviation(States state) => AbbreviationAttribute.GetAbbreviation(state);