NameValueCollection 建構函式

定義

初始化 NameValueCollection 類別的新執行個體。Initializes a new instance of the NameValueCollection class.

多載

NameValueCollection()

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有預設的初始容量,並使用預設不區分大小寫的雜湊碼提供者和預設不區分大小寫的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer.

NameValueCollection(IEqualityComparer)

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有預設的初始容量,並使用指定的 IEqualityComparer 物件。Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity, and uses the specified IEqualityComparer object.

NameValueCollection(NameValueCollection)

從指定的 NameValueCollection 複製項目至新的 NameValueCollection,使其具有與複製的項目數相同的初始容量,並使用與來源集合相同的雜湊碼提供者和相同的比較子。Copies the entries from the specified NameValueCollection to a new NameValueCollection with the same initial capacity as the number of entries copied and using the same hash code provider and the same comparer as the source collection.

NameValueCollection(Int32)

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有指定的初始容量,並使用預設不區分大小寫的雜湊碼提供者和預設不區分大小寫的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer.

NameValueCollection(IHashCodeProvider, IComparer)
已過時。

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有預設的初始容量,並使用指定的雜湊碼提供者和指定的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity and uses the specified hash code provider and the specified comparer.

NameValueCollection(Int32, IEqualityComparer)

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有指定的初始容量,並使用指定的 IEqualityComparer 物件。Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity, and uses the specified IEqualityComparer object.

NameValueCollection(Int32, NameValueCollection)

從指定的 NameValueCollection 複製項目至新的 NameValueCollection,使其具有指定的初始容量,或是與複製的項目數相同的初始容量 (取較大者),並使用預設不區分大小寫的雜湊碼提供者和預設不區分大小寫的比較子。Copies the entries from the specified NameValueCollection to a new NameValueCollection with the specified initial capacity or the same initial capacity as the number of entries copied, whichever is greater, and using the default case-insensitive hash code provider and the default case-insensitive comparer.

NameValueCollection(SerializationInfo, StreamingContext)

初始化 NameValueCollection 類別的新執行個體,這個執行個體可序列化,並使用指定的 SerializationInfoStreamingContextInitializes a new instance of the NameValueCollection class that is serializable and uses the specified SerializationInfo and StreamingContext.

NameValueCollection(Int32, IHashCodeProvider, IComparer)
已過時。

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有指定的初始容量,並使用指定的雜湊碼提供者和指定的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer.

NameValueCollection()

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有預設的初始容量,並使用預設不區分大小寫的雜湊碼提供者和預設不區分大小寫的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer.

public:
 NameValueCollection();
public NameValueCollection ();
Public Sub New ()

備註

的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 預設雜湊程式碼提供者為 CaseInsensitiveHashCodeProviderThe default hash code provider is the CaseInsensitiveHashCodeProvider.

比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal. 預設比較子是 CaseInsensitiveComparerThe default comparer is the CaseInsensitiveComparer.

此函式是 O (1) 作業。This constructor is an O(1) operation.

另請參閱

適用於

NameValueCollection(IEqualityComparer)

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有預設的初始容量,並使用指定的 IEqualityComparer 物件。Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity, and uses the specified IEqualityComparer object.

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 物件,可用來判斷兩個索引鍵是否相等,以及為集合中的索引鍵產生雜湊碼。The IEqualityComparer object to use to determine whether two keys are equal and to generate hash codes for the keys in the collection.

備註

物件的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection object is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

IEqualityComparer物件結合了比較子和雜湊程式碼提供者。The IEqualityComparer object combines the comparer and the hash code provider. 雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal.

此函式是 O (1) 作業。This constructor is an O(1) operation.

另請參閱

適用於

NameValueCollection(NameValueCollection)

從指定的 NameValueCollection 複製項目至新的 NameValueCollection,使其具有與複製的項目數相同的初始容量,並使用與來源集合相同的雜湊碼提供者和相同的比較子。Copies the entries from the specified NameValueCollection to a new NameValueCollection with the same initial capacity as the number of entries copied and using the same hash code provider and the same comparer as the source collection.

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
NameValueCollection

要複製到新的 NameValueCollection 執行個體的 NameValueCollectionThe NameValueCollection to copy to the new NameValueCollection instance.

例外狀況

colnullcol is null.

備註

的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 預設雜湊程式碼提供者為 CaseInsensitiveHashCodeProviderThe default hash code provider is the CaseInsensitiveHashCodeProvider.

比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal. 預設比較子是 CaseInsensitiveComparerThe default comparer is the CaseInsensitiveComparer.

新的元素會依照與 NameValueCollection 來源相同的順序來排序 NameValueCollectionThe elements of the new NameValueCollection are sorted in the same order as the source NameValueCollection.

此函式是 O (n) 作業,其中 n 是中的元素數目 colThis constructor is an O(n) operation, where n is the number of elements in col.

另請參閱

適用於

NameValueCollection(Int32)

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有指定的初始容量,並使用預設不區分大小寫的雜湊碼提供者和預設不區分大小寫的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer.

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 可包含的初始項目數。The initial number of entries that the NameValueCollection can contain.

例外狀況

capacity 小於零。capacity is less than zero.

備註

的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 預設雜湊程式碼提供者為 CaseInsensitiveHashCodeProviderThe default hash code provider is the CaseInsensitiveHashCodeProvider.

比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal. 預設比較子是 CaseInsensitiveComparerThe default comparer is the CaseInsensitiveComparer.

此函式是 O (n) 作業,其中 ncapacityThis constructor is an O(n) operation, where n is capacity.

另請參閱

適用於

NameValueCollection(IHashCodeProvider, IComparer)

警告

Please use NameValueCollection(IEqualityComparer) instead.

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有預設的初始容量,並使用指定的雜湊碼提供者和指定的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity and uses the specified hash code provider and the specified comparer.

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 中的所有索引鍵提供雜湊碼。The IHashCodeProvider that will supply the hash codes for all keys in the NameValueCollection.

comparer
IComparer

IComparer,可用來判斷兩個索引鍵是否相等。The IComparer to use to determine whether two keys are equal.

屬性

備註

的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 預設雜湊程式碼提供者為 CaseInsensitiveHashCodeProviderThe default hash code provider is the CaseInsensitiveHashCodeProvider.

比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal. 預設比較子是 CaseInsensitiveComparerThe default comparer is the CaseInsensitiveComparer.

此函式是 O (1) 作業。This constructor is an O(1) operation.

另請參閱

適用於

NameValueCollection(Int32, IEqualityComparer)

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有指定的初始容量,並使用指定的 IEqualityComparer 物件。Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity, and uses the specified IEqualityComparer object.

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 物件可包含的初始項目數。The initial number of entries that the NameValueCollection object can contain.

equalityComparer
IEqualityComparer

IEqualityComparer 物件,可用來判斷兩個索引鍵是否相等,以及為集合中的索引鍵產生雜湊碼。The IEqualityComparer object to use to determine whether two keys are equal and to generate hash codes for the keys in the collection.

例外狀況

capacity 小於零。capacity is less than zero.

備註

物件的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection object is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

IEqualityComparer物件結合了比較子和雜湊程式碼提供者。The IEqualityComparer object combines the comparer and the hash code provider. 雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal.

此函式是 O (n) 運算,其中 ncapacity 參數。This constructor is an O(n) operation, where n is the capacity parameter.

另請參閱

適用於

NameValueCollection(Int32, NameValueCollection)

從指定的 NameValueCollection 複製項目至新的 NameValueCollection,使其具有指定的初始容量,或是與複製的項目數相同的初始容量 (取較大者),並使用預設不區分大小寫的雜湊碼提供者和預設不區分大小寫的比較子。Copies the entries from the specified NameValueCollection to a new NameValueCollection with the specified initial capacity or the same initial capacity as the number of entries copied, whichever is greater, and using the default case-insensitive hash code provider and the default case-insensitive comparer.

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 可包含的初始項目數。The initial number of entries that the NameValueCollection can contain.

col
NameValueCollection

要複製到新的 NameValueCollection 執行個體的 NameValueCollectionThe NameValueCollection to copy to the new NameValueCollection instance.

例外狀況

capacity 小於零。capacity is less than zero.

colnullcol is null.

備註

的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 預設雜湊程式碼提供者為 CaseInsensitiveHashCodeProviderThe default hash code provider is the CaseInsensitiveHashCodeProvider.

比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal. 預設比較子是 CaseInsensitiveComparerThe default comparer is the CaseInsensitiveComparer.

此函式是 O (n) 作業,其中 ncapacityThis constructor is an O(n) operation, where n is capacity. 如果中的專案數 col 大於 capacity ,則此函式會變成 O (n + m) 作業,其中 ncapacity ,而 m 是中的元素數目 colIf the number of elements in col is greater than capacity, this constructor becomes an O(n + m) operation, where n is capacity and m is the number of elements in col.

另請參閱

適用於

NameValueCollection(SerializationInfo, StreamingContext)

初始化 NameValueCollection 類別的新執行個體,這個執行個體可序列化,並使用指定的 SerializationInfoStreamingContextInitializes a new instance of the NameValueCollection class that is serializable and uses the specified SerializationInfo and 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 執行個體序列化所需的資訊。A SerializationInfo object that contains the information required to serialize the new NameValueCollection instance.

context
StreamingContext

StreamingContext 物件,包含與新 NameValueCollection 執行個體相關聯之已序列資料流的來源和目的地。A StreamingContext object that contains the source and destination of the serialized stream associated with the new NameValueCollection instance.

備註

此函式是 O (1) 作業。This constructor is an O(1) operation.

另請參閱

適用於

NameValueCollection(Int32, IHashCodeProvider, IComparer)

警告

Please use NameValueCollection(Int32, IEqualityComparer) instead.

初始化 NameValueCollection 類別的新執行個體,這個執行個體是空白的、具有指定的初始容量,並使用指定的雜湊碼提供者和指定的比較子。Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer.

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 可包含的初始項目數。The initial number of entries that the NameValueCollection can contain.

hashProvider
IHashCodeProvider

IHashCodeProvider,將為 NameValueCollection 中的所有索引鍵提供雜湊碼。The IHashCodeProvider that will supply the hash codes for all keys in the NameValueCollection.

comparer
IComparer

IComparer,可用來判斷兩個索引鍵是否相等。The IComparer to use to determine whether two keys are equal.

屬性

例外狀況

capacity 小於零。capacity is less than zero.

備註

的容量 NameValueCollection 是可以保存的元素數目 NameValueCollectionThe capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. 當專案加入至時 NameValueCollection ,會視需要重新配置內部陣列,自動增加容量。As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

如果可以預估集合的大小,指定初始容量,就不需要在將專案加入至時執行數個調整大小作業 NameValueCollectionIf the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the NameValueCollection.

雜湊程式碼提供者會不表達中索引鍵的雜湊碼 NameValueCollectionThe hash code provider dispenses hash codes for keys in the NameValueCollection. 預設雜湊程式碼提供者為 CaseInsensitiveHashCodeProviderThe default hash code provider is the CaseInsensitiveHashCodeProvider.

比較子會判斷兩個索引鍵是否相等。The comparer determines whether two keys are equal. 預設比較子是 CaseInsensitiveComparerThe default comparer is the CaseInsensitiveComparer.

此函式是 O (n) 作業,其中 ncapacityThis constructor is an O(n) operation, where n is capacity.

另請參閱

適用於