System.Configuration.ConfigurationSectionCollection 类

方法描述

表示配置文件中的相关节的集合。

语法定义(C# System.Configuration.ConfigurationSectionCollection 类 的用法)

[SerializableAttribute]
public sealed class ConfigurationSectionCollection : NameObjectCollectionBase

构造函数

构造函数名称 构造函数描述

成员/方法

方法名称 方法描述
Add 向 ConfigurationSectionCollection 对象中添加 ConfigurationSection 对象。
BaseAdd 将具有指定键和值的项添加到 NameObjectCollectionBase 实例中。 (继承自 NameObjectCollectionBase。)
BaseClear 移除 NameObjectCollectionBase 实例中的所有项。 (继承自 NameObjectCollectionBase。)
BaseGet(Int32) 获取 NameObjectCollectionBase 实例的指定索引处的项值。 (继承自 NameObjectCollectionBase。)
BaseGet(String) 获取 NameObjectCollectionBase 实例中第一个具有指定键的项值。 (继承自 NameObjectCollectionBase。)
BaseGetAllKeys 返回 String 数组,该数组包含 NameObjectCollectionBase 实例中的所有键。 (继承自 NameObjectCollectionBase。)
BaseGetAllValues() 返回 Object 数组,该数组包含 NameObjectCollectionBase 实例中的所有值。 (继承自 NameObjectCollectionBase。)
BaseGetAllValues(Type) 返回指定类型的数组,该数组包含 NameObjectCollectionBase 实例中的所有值。 (继承自 NameObjectCollectionBase。)
BaseGetKey 获取 NameObjectCollectionBase 实例的指定索引处的项键。 (继承自 NameObjectCollectionBase。)
BaseHasKeys 获取一个值,通过该值指示 NameObjectCollectionBase 实例是否包含键不为 null 的项。 (继承自 NameObjectCollectionBase。)
BaseRemove 移除 NameObjectCollectionBase 实例中具有指定键的项。 (继承自 NameObjectCollectionBase。)
BaseRemoveAt 移除 NameObjectCollectionBase 实例的指定索引处的项。 (继承自 NameObjectCollectionBase。)
BaseSet(Int32, Object) 设置 NameObjectCollectionBase 实例的指定索引处的项值。 (继承自 NameObjectCollectionBase。)
BaseSet(String, Object) 为 NameObjectCollectionBase 实例中第一个具有指定键的项设置值(如果有这样的项);否则将具有指定键和值的项添加到 NameObjectCollectionBase 实例中。 (继承自 NameObjectCollectionBase。)
Clear 清除此 ConfigurationSectionCollection 对象。
CopyTo 将此 ConfigurationSectionCollection 对象复制到数组。
Equals(Object) 确定指定的 Object 是否等于当前的 Object。 (继承自 Object。)
Finalize 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。)
Get(Int32) 获取此 ConfigurationSectionCollection 对象中包含的指定 ConfigurationSection 对象。
Get(String) 获取此 ConfigurationSectionCollection 对象中包含的指定 ConfigurationSection 对象。
GetEnumerator 获取一个可循环访问此 ConfigurationSectionCollection 对象的枚举数。 (重写 NameObjectCollectionBase.GetEnumerator()。)
GetHashCode 用作特定类型的哈希函数。 (继承自 Object。)
GetKey 获取此 ConfigurationSectionCollection 对象中包含的指定 ConfigurationSection 对象的键。
GetObjectData 由系统在序列化期间使用。 (重写 NameObjectCollectionBase.GetObjectData(SerializationInfo, StreamingContext)。)
GetType 获取当前实例的 Type。 (继承自 Object。)
MemberwiseClone 创建当前 Object 的浅表副本。 (继承自 Object。)
OnDeserialization 实现 ISerializable 接口,并在完成反序列化之后引发反序列化事件。 (继承自 NameObjectCollectionBase。)
Remove 从此 ConfigurationSectionCollection 对象中移除指定的 ConfigurationSection 对象。
RemoveAt 从此 ConfigurationSectionCollection 对象中移除指定的 ConfigurationSection 对象。
ToString 返回表示当前对象的字符串。 (继承自 Object。)

提示和注释

使用 ConfigurationSectionCollection 类循环访问 ConfigurationSection 对象的集合。 可以使用 Sections 属性或 Sections 属性访问此对象集合。

在创建扩展 ConfigurationSection 类的自定义类型时,也会用到 ConfigurationSectionCollection 类。

System.Configuration.ConfigurationSectionCollection 类例子

下面的示例摘自上一示例所用的配置文件。



  

    

继承层次结构

System.Object

System.Collections.Specialized.NameObjectCollectionBase

System.Configuration.ConfigurationSectionCollection

命名空间

namespace: System.Configuration

程序集: System.Configuration(在 System.Configuration.dll 中)

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

版本信息

.NET Framework 受以下版本支持:4、3.5、3.0、2.0 .NET Framework Client Profile 受以下版本支持:4、3.5 SP1

适用平台

Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2 .NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。