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);
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)
参数
要复制到新 NameValueCollection 实例的 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.
注意
This constructor has been deprecated. Use NameValueCollection(IEqualityComparer) instead.
初始化 NameValueCollection 类的新实例,该实例为空且具有默认初始容量,并使用指定的哈希代码提供程序和指定的比较器。
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);
[System.Obsolete("This constructor has been deprecated. Use NameValueCollection(IEqualityComparer) instead.")]
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);
public NameValueCollection (System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
[<System.Obsolete("Please use NameValueCollection(IEqualityComparer) instead.")>]
new System.Collections.Specialized.NameValueCollection : System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
[<System.Obsolete("This constructor has been deprecated. Use NameValueCollection(IEqualityComparer) instead.")>]
new System.Collections.Specialized.NameValueCollection : System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
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) 操作。
另请参阅
适用于
NameValueCollection(Int32, IEqualityComparer)
初始化 NameValueCollection 类的新实例,该实例为空、具有指定的初始容量并使用指定的 IEqualityComparer 对象。
public:
NameValueCollection(int capacity, System::Collections::IEqualityComparer ^ equalityComparer);
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)
将项从指定的 NameValueCollection 复制到一个新的 NameValueCollection,这个新集合使用指定的初始容量或与具有与复制的项数相等的初始容量(两者中较大的一个),并使用不区分大小写的默认哈希代码提供程序和不区分大小写的默认比较器。
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 可包含的初始项数。
要复制到新 NameValueCollection 实例的 NameValueCollection。
例外
capacity
小于零。
col
为 null
。
注解
容量 NameValueCollection 是可以容纳的元素 NameValueCollection 数。 随着元素添加到 a NameValueCollection,重新分配内部数组,容量会自动增加。
如果可以估计集合的大小,则指定初始容量无需在向集合 NameValueCollection中添加元素时执行大量大小调整操作。
哈希代码提供程序为密钥 NameValueCollection分配哈希代码。 默认哈希代码提供程序为 CaseInsensitiveHashCodeProvider.
比较器确定两个键是否相等。 默认比较器是 CaseInsensitiveComparer。
此构造函数是 O (n
) 操作,其中n
。capacity
如果中的col
元素数大于capacity
,则此构造函数将成为 O (m
n
+ ) 操作,其中以及m
其中的n``capacity
元素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.
注意
This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.
初始化 NameValueCollection 类的新实例,该实例为空且具有指定的初始容量,并使用指定的哈希代码提供程序和指定的比较器。
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);
[System.Obsolete("This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.")]
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);
public NameValueCollection (int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
[<System.Obsolete("Please use NameValueCollection(Int32, IEqualityComparer) instead.")>]
new System.Collections.Specialized.NameValueCollection : int * System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
[<System.Obsolete("This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.")>]
new System.Collections.Specialized.NameValueCollection : int * System.Collections.IHashCodeProvider * System.Collections.IComparer -> System.Collections.Specialized.NameValueCollection
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