1/// <summary>
2 /// this checks if the string is a valid state abbreviation
3 /// </summary>
4 /// <param name="state"></param>
5 /// <returns>bool</returns>
6 public static bool CheckValidState(string state)
7 {
8 if (String.IsNullOrEmpty(state)) return false;
9 string[] arrStates = { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID",
10 "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE",
11 "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN",
12 "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" };
13 try
14 {
15 foreach (string s in arrStates)
16 {
17 if (state.ToUpper() == s)
18 {
19 //break out found a match
20 return true;
21 }
22 }
23 }
24 catch
25 {
26 return false;
27 }
28 //must not have found a match
29 return false;
30 }