NameValueCollection 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 NameValueCollection 类的新实例。
重载
NameValueCollection()
初始化为空的 NameValueCollection 类的新实例,具有默认的初始容量,并使用默认不区分大小写的哈希代码提供程序和默认不区分大小写的比较器。
public:
NameValueCollection();
public NameValueCollection();
Public Sub New ()
注解
一个 NameValueCollection 元素的容量是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
哈希代码提供程序为键 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器为 CaseInsensitiveComparer.
此构造函数是 O(1) 操作。
另请参阅
适用于
NameValueCollection(IEqualityComparer)
初始化为空的 NameValueCollection 类的新实例,具有默认的初始容量,并使用指定的 IEqualityComparer 对象。
public:
NameValueCollection(System::Collections::IEqualityComparer ^ equalityComparer);
public NameValueCollection(System.Collections.IEqualityComparer equalityComparer);
new System.Collections.Specialized.NameValueCollection : System.Collections.IEqualityComparer -> System.Collections.Specialized.NameValueCollection
Public Sub New (equalityComparer As IEqualityComparer)
参数
- equalityComparer
- IEqualityComparer
IEqualityComparer用于确定两个键是否相等以及为集合中的键生成哈希代码的对象。
注解
对象的容量 NameValueCollection 是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
该 IEqualityComparer 对象合并了比较器和哈希代码提供程序。 哈希代码提供程序为键 NameValueCollection分配哈希代码。 比较器确定两个键是否相等。
此构造函数是 O(1) 操作。
另请参阅
适用于
NameValueCollection(NameValueCollection)
将指定的 NameValueCollection 条目复制到 NameValueCollection 与复制的条目数相同的新项,并使用与源集合相同的哈希代码提供程序和相同的比较器。
public:
NameValueCollection(System::Collections::Specialized::NameValueCollection ^ col);
public NameValueCollection(System.Collections.Specialized.NameValueCollection col);
new System.Collections.Specialized.NameValueCollection : System.Collections.Specialized.NameValueCollection -> System.Collections.Specialized.NameValueCollection
Public Sub New (col As NameValueCollection)
参数
例外
col 是 null。
注解
一个 NameValueCollection 元素的容量是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
哈希代码提供程序为键 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器为 CaseInsensitiveComparer.
新 NameValueCollection 元素的排序顺序与源 NameValueCollection相同。
此构造函数是一个 O(n) 操作,其中 n 元素的数目 col。
另请参阅
适用于
NameValueCollection(Int32)
初始化为空的 NameValueCollection 类的新实例,具有指定的初始容量,并使用默认不区分大小写的哈希代码提供程序和默认不区分大小写的比较器。
public:
NameValueCollection(int capacity);
public NameValueCollection(int capacity);
new System.Collections.Specialized.NameValueCollection : int -> System.Collections.Specialized.NameValueCollection
Public Sub New (capacity As Integer)
参数
- capacity
- Int32
可以包含的初始条目 NameValueCollection 数。
例外
capacity 小于零。
注解
一个 NameValueCollection 元素的容量是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
哈希代码提供程序为键 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器为 CaseInsensitiveComparer.
此构造函数是 O(n) 操作,其中 n 。capacity
另请参阅
适用于
NameValueCollection(IHashCodeProvider, IComparer)
注意
Please use NameValueCollection(IEqualityComparer) instead.
初始化为空的 NameValueCollection 类的新实例,具有默认的初始容量,并使用指定的哈希代码提供程序和指定的比较器。
public:
NameValueCollection(System::Collections::IHashCodeProvider ^ hashProvider, System::Collections::IComparer ^ comparer);
public NameValueCollection(System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
[System.Obsolete("Please use NameValueCollection(IEqualityComparer) instead.")]
public NameValueCollection(System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
new System.Collections.Specialized.NameValueCollection : System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
[<System.Obsolete("Please use NameValueCollection(IEqualityComparer) instead.")>]
new System.Collections.Specialized.NameValueCollection : System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
Public Sub New (hashProvider As IHashCodeProvider, comparer As IComparer)
参数
- hashProvider
- IHashCodeProvider
这将为 IHashCodeProvider 中的所有 NameValueCollection键提供哈希代码。
- 属性
注解
一个 NameValueCollection 元素的容量是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
哈希代码提供程序为键 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器为 CaseInsensitiveComparer.
此构造函数是 O(1) 操作。
另请参阅
- IHashCodeProvider
- CaseInsensitiveHashCodeProvider
- IComparer
- CaseInsensitiveComparer
- 执行 Culture-Insensitive 字符串操作
适用于
NameValueCollection(Int32, IEqualityComparer)
初始化为空的 NameValueCollection 类的新实例,具有指定的初始容量,并使用指定的 IEqualityComparer 对象。
public:
NameValueCollection(int capacity, System::Collections::IEqualityComparer ^ equalityComparer);
public NameValueCollection(int capacity, System.Collections.IEqualityComparer equalityComparer);
new System.Collections.Specialized.NameValueCollection : int * System.Collections.IEqualityComparer -> System.Collections.Specialized.NameValueCollection
Public Sub New (capacity As Integer, equalityComparer As IEqualityComparer)
参数
- capacity
- Int32
对象可以包含的初始条目 NameValueCollection 数。
- equalityComparer
- IEqualityComparer
IEqualityComparer用于确定两个键是否相等以及为集合中的键生成哈希代码的对象。
例外
capacity 小于零。
注解
对象的容量 NameValueCollection 是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
该 IEqualityComparer 对象合并了比较器和哈希代码提供程序。 哈希代码提供程序为键 NameValueCollection分配哈希代码。 比较器确定两个键是否相等。
此构造函数是一个 O(n) 操作,其中 n 是 capacity 参数。
另请参阅
适用于
NameValueCollection(Int32, NameValueCollection)
将指定的NameValueCollectionNameValueCollection条目复制到具有指定初始容量的新项,或与复制的条目数相同的初始容量(以较大者为准),并使用默认不区分大小写的哈希代码提供程序和默认不区分大小写的比较器。
public:
NameValueCollection(int capacity, System::Collections::Specialized::NameValueCollection ^ col);
public NameValueCollection(int capacity, System.Collections.Specialized.NameValueCollection col);
new System.Collections.Specialized.NameValueCollection : int * System.Collections.Specialized.NameValueCollection -> System.Collections.Specialized.NameValueCollection
Public Sub New (capacity As Integer, col As NameValueCollection)
参数
- capacity
- Int32
可以包含的初始条目 NameValueCollection 数。
例外
capacity 小于零。
col 是 null。
注解
一个 NameValueCollection 元素的容量是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
哈希代码提供程序为键 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器为 CaseInsensitiveComparer.
此构造函数是 O(n) 操作,其中 n 。capacity 如果中的col元素数大于capacity,则此构造函数将变为 O( + nm)操作,其中是capacity元素数,m并且n是其中的col元素数。
另请参阅
适用于
NameValueCollection(SerializationInfo, StreamingContext)
初始化可序列化的 NameValueCollection 类的新实例,并使用指定的 SerializationInfo 和 StreamingContext。
protected:
NameValueCollection(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected NameValueCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Collections.Specialized.NameValueCollection : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Specialized.NameValueCollection
Protected Sub New (info As SerializationInfo, context As StreamingContext)
参数
- info
- SerializationInfo
包含 SerializationInfo 序列化新 NameValueCollection 实例所需的信息的对象。
- context
- StreamingContext
一个 StreamingContext 对象,该对象包含与新 NameValueCollection 实例关联的序列化流的源和目标。
注解
此构造函数是 O(1) 操作。
另请参阅
适用于
NameValueCollection(Int32, IHashCodeProvider, IComparer)
注意
Please use NameValueCollection(Int32, IEqualityComparer) instead.
初始化为空的 NameValueCollection 类的新实例,具有指定的初始容量,并使用指定的哈希代码提供程序和指定的比较器。
public:
NameValueCollection(int capacity, System::Collections::IHashCodeProvider ^ hashProvider, System::Collections::IComparer ^ comparer);
public NameValueCollection(int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
[System.Obsolete("Please use NameValueCollection(Int32, IEqualityComparer) instead.")]
public NameValueCollection(int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
new System.Collections.Specialized.NameValueCollection : int * System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
[<System.Obsolete("Please use NameValueCollection(Int32, IEqualityComparer) instead.")>]
new System.Collections.Specialized.NameValueCollection : int * System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
Public Sub New (capacity As Integer, hashProvider As IHashCodeProvider, comparer As IComparer)
参数
- capacity
- Int32
可以包含的初始条目 NameValueCollection 数。
- hashProvider
- IHashCodeProvider
这将为 IHashCodeProvider 中的所有 NameValueCollection键提供哈希代码。
- 属性
例外
capacity 小于零。
注解
一个 NameValueCollection 元素的容量是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合中添加元素 NameValueCollection时执行大量调整大小操作。
哈希代码提供程序为键 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器为 CaseInsensitiveComparer.
此构造函数是 O(n) 操作,其中 n 。capacity