配置文件:
<
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 >
< 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 >
应用:System.Collections.Specialized.NameValueCollection
NameValueCollection nv = (NameValueCollection) ConfigurationSettings.GetConfig("mySectionGroup/mySection");
Console.WriteLine(nv["key1"]);