Export (0) Print
Expand All

NameObjectCollectionBase Class

Provides the abstract base class for a collection of associated String keys and Object values that can be accessed either with the key or with the index.

System.Object
  System.Collections.Specialized.NameObjectCollectionBase
    More...

Namespace:  System.Collections.Specialized
Assembly:  System (in System.dll)

[<AbstractClass>]
[<SerializableAttribute>]
type NameObjectCollectionBase =  
    class 
        interface ICollection 
        interface IEnumerable 
        interface ISerializable 
        interface IDeserializationCallback 
    end

The NameObjectCollectionBase type exposes the following members.

  NameDescription
Protected methodSupported by the XNA FrameworkNameObjectCollectionBase()Initializes a new instance of the NameObjectCollectionBase class that is empty.
Protected methodSupported by the XNA FrameworkNameObjectCollectionBase(IEqualityComparer)Initializes a new instance of the NameObjectCollectionBase class that is empty, has the default initial capacity, and uses the specified IEqualityComparer object.
Protected methodSupported by the XNA FrameworkNameObjectCollectionBase(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.
Protected methodSupported by the XNA FrameworkNameObjectCollectionBase(IHashCodeProvider, IComparer) 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.
Protected methodSupported by the XNA FrameworkNameObjectCollectionBase(Int32, IEqualityComparer)Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity, and uses the specified IEqualityComparer object.
Protected methodNameObjectCollectionBase(SerializationInfo, StreamingContext)Initializes a new instance of the NameObjectCollectionBase class that is serializable and uses the specified System.Runtime.Serialization.SerializationInfo and System.Runtime.Serialization.StreamingContext.
Protected methodSupported by the XNA FrameworkNameObjectCollectionBase(Int32, IHashCodeProvider, IComparer) 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.
Top

  NameDescription
Public propertySupported by the XNA FrameworkCountGets the number of key/value pairs contained in the NameObjectCollectionBase instance.
Protected propertySupported by the XNA FrameworkIsReadOnlyGets or sets a value indicating whether the NameObjectCollectionBase instance is read-only.
Public propertySupported by the XNA FrameworkKeysGets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance.
Top

  NameDescription
Protected methodSupported by the XNA FrameworkBaseAddAdds an entry with the specified key and value into the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseClearRemoves all entries from the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseGet(Int32)Gets the value of the entry at the specified index of the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseGet(String)Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseGetAllKeysReturns a String array that contains all the keys in the NameObjectCollectionBase instance.
Protected methodBaseGetAllValues()Returns an Object array that contains all the values in the NameObjectCollectionBase instance.
Protected methodBaseGetAllValues(Type)Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseGetKeyGets the key of the entry at the specified index of the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseHasKeysGets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not a null reference (Nothing in Visual Basic).
Protected methodSupported by the XNA FrameworkBaseRemoveRemoves the entries with the specified key from the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseRemoveAtRemoves the entry at the specified index of the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseSet(Int32, Object)Sets the value of the entry at the specified index of the NameObjectCollectionBase instance.
Protected methodSupported by the XNA FrameworkBaseSet(String, Object)Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance.
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetEnumeratorReturns an enumerator that iterates through the NameObjectCollectionBase.
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetObjectDataImplements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance.
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodOnDeserializationImplements the ISerializable interface and raises the deserialization event when the deserialization is complete.
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodSupported by the XNA FrameworkCast(TResult)Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodSupported by the XNA FrameworkOfType(TResult)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodSupported by the XNA FrameworkICollection.CopyToCopies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.
Explicit interface implemetationPrivate propertySupported by the XNA FrameworkICollection.IsSynchronizedGets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe).
Explicit interface implemetationPrivate propertySupported by the XNA FrameworkICollection.SyncRootGets an object that can be used to synchronize access to the NameObjectCollectionBase object.
Top

The underlying structure for this class is a hash table.

Each element is a key/value pair.

The capacity of a NameObjectCollectionBase is the number of elements the NameObjectCollectionBase can hold. As elements are added to a NameObjectCollectionBase, the capacity is automatically increased as required through reallocation.

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.

In .NET Framework version 1.0, this class uses culture-sensitive string comparisons. However, in .NET Framework version 1.1 and later, this class uses CultureInfo.InvariantCulture when comparing strings. For more information about how culture affects comparisons and sorting, see <PAVE OVER> Comparing and Sorting Data for a Specific Culture <PAVE OVER> Comparing and Sorting Data for a Specific Cultureand Performing Culture-Insensitive String Operations.

a null reference (Nothing in Visual Basic) is allowed as a key or as a value.

Caution noteCaution

The BaseGet method does not distinguish between a null reference (Nothing in Visual Basic) which is returned because the specified key is not found and a null reference (Nothing in Visual Basic) which is returned because the value associated with the key is a null reference (Nothing in Visual Basic).

The following code example shows how to implement and use the NameObjectCollectionBase class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

This implementation does not provide a synchronized (thread safe) wrapper for a NameObjectCollectionBase, but derived classes can create their own synchronized versions of the NameObjectCollectionBase using the SyncRoot property.

Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

Show:
© 2014 Microsoft