<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users1749</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/1749" rel="self"/>
  <title>neiled</title>
  <updated>Thu Oct 08 16:07:03 -0700 2009</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code1063</id>
    <published>2009-10-08T16:07:03-07:00</published>
    <updated>2010-06-14T15:29:11-07:00</updated>
    <title>[C#] Comma separated string to Dictionary</title>
    <content type="html">&lt;p&gt;Anyone up for the challenge of getting this down to one line of code? I could do it in ruby :)&lt;/p&gt;

&lt;p&gt;&amp;quot;A,B,C,D&amp;quot;
&lt;br /&gt;should become
&lt;br /&gt;[&amp;quot;A&amp;quot;,1],[&amp;quot;B&amp;quot;,2]..etc&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;

&lt;pre&gt;int count = 0;
Dictionary&amp;lt;string,int&amp;gt; headers = line.Split(',').ToDictionary(y =&amp;gt; y, y =&amp;gt; count++);&lt;/pre&gt;</content>
    <author>
      <name>neiled</name>
      <email>neil@plasticwater.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/1063-comma-separated-string-to-dictionary" rel="alternate"/>
  </entry>
</feed>

