配置文件: <configuration> <configSections> <sectionGroup name="mySectionGroup"> <section name="mySection" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.2411.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowLocation="false"/> </sectionGroup> </configSections> <mySectionGroup> <mySection> <add key="key1" value="value1" /> </mySection> </mySectionGroup> </configuration> winForm应用程序的默认配置文件是App.config。 应用:System.Collections.Specialized.NameValueCollection NameValueCollection nv = (NameValueCollection) ConfigurationSettings.GetConfig("mySectionGroup/mySection"); Console.WriteLine(nv["key1"]);