当我们程序中使用配置文件时,Asp.net中使用是Web.config,WinForm和Console中使用是App.config。通常用的最多是AppSettings节,有的时候觉得不够用,另一选择就是自己实现SectionHandler,来实现自定义配置节。看下面的示例AppSettings节:
对于上面两个配置项,要写个自定义配置类是不是很麻烦,我们还有另一种简单实现方法,使用 SingleTagSectionHandler
MSDN是这么描述的:Handles configuration sections that are represented by a single XML tag in the .config file".
下面来看一下:
代码中这样访问:
转自:http://www.cnblogs.com/wintersun/archive/2008/11/23/1339430.html