bom*_*mbo 5 c# configurationsection
我的Web.config文件中有以下部分:
<configSections>
    <section name="mySection" type="myNameSpace, myProject"/>
</configSections>
<mySection>
    <city id="ny" type="nameSpace1" />
    <city id="dc" type="nameSpace2" />
    <city id="nj" type="nameSpace3" />
</mySection>
我需要编写循环遍历cities给定的代码id并返回type.
即
 if the given id = "ny" --> return nameSpace1
 if the given id = "dc" --> return nameSpace2
 if the given id = "nj" --> return nameSpace3
您需要参考以下部分:
var theSection = (TypeOfSection)ConfigurationManager.GetSection("mySection");
请注意对TypeOfSection- 这是配置文件中声明的类型。
此时,您应该拥有一个可以访问和迭代的强类型对象。
| 归档时间: | 
 | 
| 查看次数: | 1728 次 | 
| 最近记录: |