C# asp.net 节点问题

来源:百度知道 编辑:UC知道 时间:2024/07/07 17:13:30
HttpRuntimeSection myHttpRuntimeSection = (HttpRuntimeSection)config.GetSection("system.web/httpRuntime");
这句代码意思
GetSection方法返回的是ConfigurationSection类 但这个类又于HttpRuntimeSection什么关系.请大侠来指点

config.GetSection 方法返回的是ConfigurationSection类, 但是这个返回结果是一个 通用的 Section,并没有特定的约束和规范,

(HttpRuntimeSection)config.GetSection("system.web/httpRuntime");是一个强制的类型转换, 是将 那个通用的 Section 限定转换为 HttpRuntimeSection,这样, 就可以使用 HttpRuntimeSection 的特定属性和方法来对其进行操作了