Source Address
Http://gb2013.blog.163.com/blog/static/21735301201021253713453/
View code
<? XML version = "1.0" encoding = "UTF-8" ?> < Configuration > < Configsections > < Section Name = "Student" Type = "System. configuration. dictionarysectionhandler" /> </ Configsections > < Student > < Add Key = "Name" Value = "Amily" /> < Add Key = "Age" Value = "15" /> < Add Key = "Sex" Value = "Female" /> </ Student > </ Configuration >
Note: configsections is equivalent to defining variables and must be placed in configuration
Idictionary istudent = (idictionary) configurationmanager. getsection ( " Student " ); String [] Keys = New String [Istudent. Keys. Count]; String [] Values = New String [Istudent. Keys. Count]; istudent. Keys. copyto (keys, 0 ); Istudent. Values. copyto (values, 0 ); Foreach ( VaR Key In Keys) {console. writeline (key );} Foreach ( VaR ValueIn Values) {console. writeline (value );} Foreach ( VaR Key In Istudent. Keys) {console. writeline ( " {0 }:{ 1} " , Key, istudent [Key]);}