title: The most 'elegant' way to populate a Dictionary<String,String> from a delimited string
body: <p>I think those with even a slight grasp on basic string manipulation, loops and dictionaries can work out how to populate a Dictionary from a String such as this:</p>
  
  <p><strong>Black:#00000|Green:#008000|</strong> <em>(where "Black" is the Key and "#000000" is the Value)</em></p>
  
  <p>But what is the most 'elegant' way of doing it in your opinion? What is the most efficient/more concise coding I can use to achieve it? So far I have:</p>
  
  <pre><code>    public static Dictionary&lt;String, String&gt; ThemeColors
      {
          get
          {
              Dictionary&lt;String, String&gt; themeColors = new Dictionary&lt;string, string&gt;();
              foreach (String colorAndCode in GetSettingByName("ThemeColors").ToString().Split('|'))
              {
                  themeColors.Add(colorAndCode.Split(':').First(), colorAndCode.Split(':').Last());
              }
              return themeColors;
          }
      }
  </code></pre>
  
  <p>GetSettingByName("ThemeColours") returns the string above (in Bold).</p>
  
  <p>It's functional obviously, it all works, but I want to make sure I'm beginning to think beyond this now and working out the best way of doing things rather than just getting it working.</p>
  
  <p>Can I use a yield on the Dictionary loop for example??</p>