NameObjectCollectionBase Constructors

Definition

Initializes a new instance of the NameObjectCollectionBase class.

Overloads

NameObjectCollectionBase()

Initializes a new instance of the NameObjectCollectionBase class that is empty.

NameObjectCollectionBase(IEqualityComparer)

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

NameObjectCollectionBase(Int32)

Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity, and uses the default hash code provider and the default comparer.

NameObjectCollectionBase(IHashCodeProvider, IComparer)
Obsolete.
Obsolete.

Initializes a new instance of the NameObjectCollectionBase class that is empty, has the default initial capacity, and uses the specified hash code provider and the specified comparer.

NameObjectCollectionBase(Int32, IEqualityComparer)

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

NameObjectCollectionBase(SerializationInfo, StreamingContext)
Obsolete.

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

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

Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer.

NameObjectCollectionBase()

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs

Initializes a new instance of the NameObjectCollectionBase class that is empty.

C#
protected NameObjectCollectionBase();

Remarks

The capacity of a NameObjectCollectionBase is the number of elements that the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, 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 NameObjectCollectionBase.

The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. 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

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

NameObjectCollectionBase(IEqualityComparer)

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs

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

C#
protected NameObjectCollectionBase(System.Collections.IEqualityComparer equalityComparer);
C#
protected NameObjectCollectionBase(System.Collections.IEqualityComparer? equalityComparer);

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 NameObjectCollectionBase object is the number of elements that the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, 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 NameObjectCollectionBase.

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

This constructor is an O(1) operation.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

NameObjectCollectionBase(Int32)

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs

Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity, and uses the default hash code provider and the default comparer.

C#
protected NameObjectCollectionBase(int capacity);

Parameters

capacity
Int32

The approximate number of entries that the NameObjectCollectionBase instance can initially contain.

Exceptions

capacity is less than zero.

Remarks

The capacity of a NameObjectCollectionBase is the number of elements that the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, 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 NameObjectCollectionBase.

The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. 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

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

NameObjectCollectionBase(IHashCodeProvider, IComparer)

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs

Caution

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

Caution

Please use NameObjectCollectionBase(IEqualityComparer) instead.

Initializes a new instance of the NameObjectCollectionBase class that is empty, has the default initial capacity, and uses the specified hash code provider and the specified comparer.

C#
[System.Obsolete("This constructor has been deprecated. Use NameObjectCollectionBase(IEqualityComparer) instead.")]
protected NameObjectCollectionBase(System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer);
C#
[System.Obsolete("Please use NameObjectCollectionBase(IEqualityComparer) instead.")]
protected NameObjectCollectionBase(System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer);
C#
[System.Obsolete("Please use NameObjectCollectionBase(IEqualityComparer) instead.")]
protected NameObjectCollectionBase(System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
C#
protected NameObjectCollectionBase(System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);

Parameters

hashProvider
IHashCodeProvider

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

comparer
IComparer

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

Attributes

Remarks

The capacity of a NameObjectCollectionBase is the number of elements that the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, 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 NameObjectCollectionBase.

The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. 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

.NET 10 and other versions
Product Versions (Obsolete)
.NET (Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10)
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)
.NET Standard (2.0, 2.1)

NameObjectCollectionBase(Int32, IEqualityComparer)

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs

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

C#
protected NameObjectCollectionBase(int capacity, System.Collections.IEqualityComparer equalityComparer);
C#
protected NameObjectCollectionBase(int capacity, System.Collections.IEqualityComparer? equalityComparer);

Parameters

capacity
Int32

The approximate number of entries that the NameObjectCollectionBase object can initially 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 NameObjectCollectionBase object is the number of elements that the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, 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 NameObjectCollectionBase.

The IEqualityComparer object combines the comparer and the hash code provider. The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase. 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

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

NameObjectCollectionBase(SerializationInfo, StreamingContext)

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.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 NameObjectCollectionBase class that is serializable and uses the specified SerializationInfo and StreamingContext.

C#
[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 NameObjectCollectionBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
C#
protected NameObjectCollectionBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);

Parameters

info
SerializationInfo

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

context
StreamingContext

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

Attributes

Remarks

This constructor is an O(1) operation.

See also

Applies to

.NET 10 and other versions
Product Versions (Obsolete)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 (8, 9, 10)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

NameObjectCollectionBase(Int32, IHashCodeProvider, IComparer)

Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs
Source:
NameObjectCollectionBase.cs

Caution

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

Caution

Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.

Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer.

C#
[System.Obsolete("This constructor has been deprecated. Use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")]
protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer);
C#
[System.Obsolete("Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")]
protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider? hashProvider, System.Collections.IComparer? comparer);
C#
[System.Obsolete("Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")]
protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);
C#
protected NameObjectCollectionBase(int capacity, System.Collections.IHashCodeProvider hashProvider, System.Collections.IComparer comparer);

Parameters

capacity
Int32

The approximate number of entries that the NameObjectCollectionBase instance can initially contain.

hashProvider
IHashCodeProvider

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

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 NameObjectCollectionBase is the number of elements that the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, 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 NameObjectCollectionBase.

The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. 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

.NET 10 and other versions
Product Versions (Obsolete)
.NET (Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10)
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)
.NET Standard (2.0, 2.1)