andrew4582

US States

Oct 8th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.83 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4.  
  5. public class MyClass
  6. {
  7.     public static void RunSnippet()
  8.     {
  9.          var dict = USStates.GetStates;
  10.  
  11.         foreach(var key in dict.Keys)
  12.         {
  13.             var val = dict[key];
  14.             Console.WriteLine("{0} = {1}",key,val);
  15.         }
  16.     }
  17.    
  18.     #region Helper methods
  19.    
  20.     public static void Main()
  21.     {
  22.         try
  23.         {
  24.             RunSnippet();
  25.         }
  26.         catch (Exception e)
  27.         {
  28.             string error = string.Format("---\nThe following error occurred while executing the snippet:\n{0}\n---", e.ToString());
  29.             Console.WriteLine(error);
  30.         }
  31.         finally
  32.         {
  33.             Console.Write("Press any key to continue...");
  34.             Console.ReadKey();
  35.         }
  36.     }
  37.  
  38.     private static void WL(object text, params object[] args)
  39.     {
  40.         Console.WriteLine(text.ToString(), args);  
  41.     }
  42.    
  43.     private static void RL()
  44.     {
  45.         Console.ReadLine();
  46.     }
  47.    
  48.     private static void Break()
  49.     {
  50.         System.Diagnostics.Debugger.Break();
  51.     }
  52.  
  53.     #endregion
  54. }
  55.  
  56. public class USStates
  57. {
  58.     readonly static Dictionary<string, string> dictionary = null;
  59.  
  60.     public static Dictionary<string, string> GetStates
  61.     {
  62.         get { return dictionary; }
  63.     }
  64.  
  65.     static USStates()
  66.     {
  67.         dictionary = new Dictionary<string, string>();
  68.         dictionary["AL"] = "Alabama";
  69.         dictionary["AK"] = "Alaska";
  70.         dictionary["AZ"] = "Arizona";
  71.         dictionary["AR"] = "Arkansas";
  72.         dictionary["CA"] = "California";
  73.         dictionary["CO"] = "Colorado";
  74.         dictionary["CT"] = "Connecticut";
  75.         dictionary["DE"] = "Delaware";
  76.         dictionary["DC"] = "District";
  77.         dictionary["FL"] = "Florida";
  78.         dictionary["GA"] = "Georgia";
  79.         dictionary["HI"] = "Hawaii";
  80.         dictionary["ID"] = "Idaho";
  81.         dictionary["IL"] = "Illinois";
  82.         dictionary["IN"] = "Indiana";
  83.         dictionary["IA"] = "Iowa";
  84.         dictionary["KS"] = "Kansas";
  85.         dictionary["KY"] = "Kentucky";
  86.         dictionary["LA"] = "Louisiana";
  87.         dictionary["ME"] = "Maine";
  88.         dictionary["MT"] = "Montana";
  89.         dictionary["NE"] = "Nebraska";
  90.         dictionary["NV"] = "Nevada";
  91.         dictionary["NH"] = "New";
  92.         dictionary["NJ"] = "New";
  93.         dictionary["NM"] = "New";
  94.         dictionary["NY"] = "New";
  95.         dictionary["NC"] = "North";
  96.         dictionary["ND"] = "North";
  97.         dictionary["OH"] = "Ohio";
  98.         dictionary["OK"] = "Oklahoma";
  99.         dictionary["OR"] = "Oregon";
  100.         dictionary["MD"] = "Maryland";
  101.         dictionary["MA"] = "Massachusetts";
  102.         dictionary["MI"] = "Michigan";
  103.         dictionary["MN"] = "Minnesota";
  104.         dictionary["MS"] = "Mississippi";
  105.         dictionary["MO"] = "Missouri";
  106.         dictionary["PA"] = "Pennsylvania";
  107.         dictionary["RI"] = "Rhode";
  108.         dictionary["SC"] = "South";
  109.         dictionary["SD"] = "South";
  110.         dictionary["TN"] = "Tennessee";
  111.         dictionary["TX"] = "Texas";
  112.         dictionary["UT"] = "Utah";
  113.         dictionary["VT"] = "Vermont";
  114.         dictionary["VA"] = "Virginia";
  115.         dictionary["WA"] = "Washington";
  116.         dictionary["WV"] = "West";
  117.         dictionary["WI"] = "Wisconsin";
  118.         dictionary["WY"] = "Wyoming";
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment