title: .NET get custom configuration section as NameValueCollection
body: <p>In my web.config , I break-out config sections into separate files : </p>
  
  <pre><code>&lt;appSettings configSource="AppSettings.config" /&gt;
  &lt;mySettings configSource="MySettings.config" /&gt;
  </code></pre>
  
  <p>Then I use the ConfigurationManager to retrieve the settings : </p>
  
  <pre><code>NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;
  </code></pre>
  
  <p>NameValueCollection is handy because I can do :  </p>
  
  <pre><code>var someSetting = appSettings["someSetting"];
  </code></pre>
  
  <p>I'd like to do the same for the custom config sections, but I can't figure out how to obtain a NameValueCollection : </p>
  
  <pre><code>Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
  ConfigurationSection section = configuration.GetSection("mySettings"); 
  KeyValueConfigurationCollection mySettings = ((AppSettingsSection)section).Settings;
  </code></pre>
  
  <p>KeyValueConfigurationCollection also works for retrieving individual settings : </p>
  
  <pre><code>var mySetting = mySettings["mySetting"].Value
  </code></pre>
  
  <p>but I'd like to represent all of my config sections as the same type for purposes of handing off to generic processing routines.</p>
  
  <p>How to obtain a NameValueCollection for a custom config section ?</p>