title: Linq to convert a string to a Dictionary<string,string>
body: <p>I'm using a dictionary to hold some parameters and I've just found out that it's not possible to serialize anything that implements IDictionary (<a href="https://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member">unable to serialize IDictionary</a>).</p>
  
  <p>As a workaround I'd like to convert may dictionary into a string for serialization and then convert back to a dictionary when required. </p>
  
  <p>As I'm trying to improve my LINQ this seems like a good place to do it but I'm not sure how to start.</p>
  
  <p>This is how I'd implement it without LINQ:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Get / Set the extended properties of the FTPS processor
  /// &lt;/summary&gt;
  /// &lt;remarks&gt;Can't serialize the Dictionary object so convert to a string (http://msdn.microsoft.com/en-us/library/ms950721.aspx)&lt;/remarks&gt;
  public Dictionary&lt;string, string&gt; FtpsExtendedProperties
  {
      get 
      {
          Dictionary&lt;string, string&gt; dict = new Dictionary&lt;string, string&gt;();
  
          // Get the Key value pairs from the string
          string[] kvpArray = m_FtpsExtendedProperties.Split('|');
  
          foreach (string kvp in kvpArray)
          {
              // Seperate the key and value to build the dictionary
              string[] pair = kvp.Split(',');
              dict.Add(pair[0], pair[1]);
          }
  
          return dict; 
      }
  
      set 
      {
          string newProperties = string.Empty;
  
          // Iterate through the dictionary converting the value pairs into a string
          foreach (KeyValuePair&lt;string,string&gt; kvp in value)
          {
              newProperties += string.Format("{0},{1}|", kvp.Key, kvp.Value);    
          }
  
          // Remove the last pipe serperator
          newProperties = newProperties.Substring(0, newProperties.Length - 1);
      }
  }
  </code></pre>