我在我的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.我确定我错过了一些简单的东西,但我找不到任何关于如何做到这一点的事情.
谢谢