title: NameValueCollection vs Dictionary<string,string>
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/617443/idictionarystring-string-or-namevaluecollection">IDictionary&lt;string, string&gt; or NameValueCollection</a>  </p>
  </blockquote>
  
  
  
  <p>Any reason I should use Dictionary&lt;string,string> instead of NameValueCollection?</p>
  
  <p>(in C# / .NET Framework)</p>
  
  <p>Option 1, using NameValueCollection:</p>
  
  <pre><code>//enter values:
  NameValueCollection nvc = new NameValueCollection()
  {
    {"key1", "value1"},
    {"key2", "value2"},
    {"key3", "value3"}
  };
  
  // retrieve values:
  foreach(string key in nvc.AllKeys)
  {
    string value = nvc[key];
    // do something
  }
  </code></pre>
  
  <p>Option 2, using Dictionary&lt;string,string>...</p>
  
  <pre><code>//enter values:
  Dictionary&lt;string, string&gt; dict = new Dictionary&lt;string, string&gt;()
  {
    {"key1", "value1"},
    {"key2", "value2"},
    {"key3", "value3"}
  };
  
  // retrieve values:
  foreach (KeyValuePair&lt;string, string&gt; kvp in dict)
  {
    string key = kvp.Key;
    string val = kvp.Value;
    // do something
  }
  </code></pre>
  
  <p>For these use cases, is there any advantage to use one versus the other? Any difference in performance, memory use, sort order, etc.?</p>