Επεξεργασία

Κοινή χρήση μέσω


NameValueCollection Constructors

Definition

Initializes a new instance of the NameValueCollection class.

Overloads

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)

Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity, and uses the specified IEqualityComparer object.

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)

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)
Obsolete.
Obsolete.

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)

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)

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)
Obsolete.

Initializes a new instance of the NameValueCollection class that is serializable and uses the specified SerializationInfo and StreamingContext.

NameValueCollection(Int32, IHashCodeProvider, IComparer)
Obsolete.
Obsolete.

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()

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

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 ()

Remarks

The capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.

This constructor is an O(1) operation.

See also

Applies to

NameValueCollection(IEqualityComparer)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

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);
public NameValueCollection (System.Collections.IEqualityComparer? equalityComparer);
new System.Collections.Specialized.NameValueCollection : System.Collections.IEqualityComparer -> System.Collections.Specialized.NameValueCollection
Public Sub New (equalityComparer As IEqualityComparer)

Parameters

equalityComparer
IEqualityComparer

The IEqualityComparer object to use to determine whether two keys are equal and to generate hash codes for the keys in the collection.

Remarks

The capacity of a NameValueCollection object is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The IEqualityComparer object combines the comparer and the hash code provider. The hash code provider dispenses hash codes for keys in the NameValueCollection. The comparer determines whether two keys are equal.

This constructor is an O(1) operation.

See also

Applies to

NameValueCollection(NameValueCollection)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

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)

Parameters

col
NameValueCollection

The NameValueCollection to copy to the new NameValueCollection instance.

Exceptions

col is null.

Remarks

The capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.

The elements of the new NameValueCollection are sorted in the same order as the source NameValueCollection.

This constructor is an O(n) operation, where n is the number of elements in col.

See also

Applies to

NameValueCollection(Int32)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

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)

Parameters

capacity
Int32

The initial number of entries that the NameValueCollection can contain.

Exceptions

capacity is less than zero.

Remarks

The capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.

This constructor is an O(n) operation, where n is capacity.

See also

Applies to

NameValueCollection(IHashCodeProvider, IComparer)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

Caution

Please use NameValueCollection(IEqualityComparer) instead.

Caution

This constructor has been deprecated. Use NameValueCollection(IEqualityComparer) instead.

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);
[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)

Parameters

hashProvider
IHashCodeProvider

The IHashCodeProvider that will supply the hash codes for all keys in the NameValueCollection.

comparer
IComparer

The IComparer to use to determine whether two keys are equal.

Attributes

Remarks

The capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.

This constructor is an O(1) operation.

See also

Applies to

NameValueCollection(Int32, IEqualityComparer)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

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);
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)

Parameters

capacity
Int32

The initial number of entries that the NameValueCollection object can contain.

equalityComparer
IEqualityComparer

The IEqualityComparer object to use to determine whether two keys are equal and to generate hash codes for the keys in the collection.

Exceptions

capacity is less than zero.

Remarks

The capacity of a NameValueCollection object is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The IEqualityComparer object combines the comparer and the hash code provider. The hash code provider dispenses hash codes for keys in the NameValueCollection. The comparer determines whether two keys are equal.

This constructor is an O(n) operation, where n is the capacity parameter.

See also

Applies to

NameValueCollection(Int32, NameValueCollection)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

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)

Parameters

capacity
Int32

The initial number of entries that the NameValueCollection can contain.

col
NameValueCollection

The NameValueCollection to copy to the new NameValueCollection instance.

Exceptions

capacity is less than zero.

col is null.

Remarks

The capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.

This constructor is an O(n) operation, where n is capacity. If 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.

See also

Applies to

NameValueCollection(SerializationInfo, StreamingContext)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes 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);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
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
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
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)

Parameters

info
SerializationInfo

A SerializationInfo object that contains the information required to serialize the new NameValueCollection instance.

context
StreamingContext

A StreamingContext object that contains the source and destination of the serialized stream associated with the new NameValueCollection instance.

Attributes

Remarks

This constructor is an O(1) operation.

See also

Applies to

NameValueCollection(Int32, IHashCodeProvider, IComparer)

Source:
NameValueCollection.cs
Source:
NameValueCollection.cs
Source:
NameValueCollection.cs

Caution

Please use NameValueCollection(Int32, IEqualityComparer) instead.

Caution

This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.

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);
[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)

Parameters

capacity
Int32

The initial number of entries that the NameValueCollection can contain.

hashProvider
IHashCodeProvider

The IHashCodeProvider that will supply the hash codes for all keys in the NameValueCollection.

comparer
IComparer

The IComparer to use to determine whether two keys are equal.

Attributes

Exceptions

capacity is less than zero.

Remarks

The capacity of a NameValueCollection is the number of elements that the NameValueCollection can hold. As elements are added to a NameValueCollection, the capacity is automatically increased as required by reallocating the internal array.

If 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.

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.

This constructor is an O(n) operation, where n is capacity.

See also

Applies to