相关疑难解决方法(0)

如何阅读configSections

我在我的App.Config中设置了一些自定义配置部分,这样我现在有一个看起来像这样的configSection.

<configSections>
    <section name="Section1" type="ConfigSections.MySection, MyNamespace"/>    
    <section name="Section2" type="ConfigSections.MySection, MyNamespace"/>    
    <section name="Section3" type="ConfigSections.MySection, MyNamespace"/>    
</configSections>
Run Code Online (Sandbox Code Playgroud)

我想要做的是在代码中阅读本节,以便在运行时找出我有哪些部分.我试过了:

var mySections = ConfigurationManager.GetSection("configSections");
Run Code Online (Sandbox Code Playgroud)

但是这会返回null.我确定我错过了一些简单的东西,但我找不到任何关于如何做到这一点的事情.

谢谢

c# app-config

4
推荐指数
1
解决办法
9096
查看次数

标签 统计

app-config ×1

c# ×1