DictionaryBase Class

 

Provides the abstract base class for a strongly typed collection of key/value pairs.

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


[<AbstractClass>]
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type DictionaryBase = 
    class
        interface IDictionary
        interface ICollection
        interface IEnumerable
    end

NameDescription
System_CAPS_protmethodDictionaryBase()

Initializes a new instance of the DictionaryBase class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of elements contained in the DictionaryBase instance.

System_CAPS_protpropertyDictionary

Gets the list of elements contained in the DictionaryBase instance.

System_CAPS_protpropertyInnerHashtable

Gets the list of elements contained in the DictionaryBase instance.

NameDescription
System_CAPS_pubmethodClear()

Clears the contents of the DictionaryBase instance.

System_CAPS_pubmethodCopyTo(Array, Int32)

Copies the DictionaryBase elements to a one-dimensional Array at the specified index.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns an IDictionaryEnumerator that iterates through the DictionaryBase instance.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnClear()

Performs additional custom processes before clearing the contents of the DictionaryBase instance.

System_CAPS_protmethodOnClearComplete()

Performs additional custom processes after clearing the contents of the DictionaryBase instance.

System_CAPS_protmethodOnGet(Object, Object)

Gets the element with the specified key and value in the DictionaryBase instance.

System_CAPS_protmethodOnInsert(Object, Object)

Performs additional custom processes before inserting a new element into the DictionaryBase instance.

System_CAPS_protmethodOnInsertComplete(Object, Object)

Performs additional custom processes after inserting a new element into the DictionaryBase instance.

System_CAPS_protmethodOnRemove(Object, Object)

Performs additional custom processes before removing an element from the DictionaryBase instance.

System_CAPS_protmethodOnRemoveComplete(Object, Object)

Performs additional custom processes after removing an element from the DictionaryBase instance.

System_CAPS_protmethodOnSet(Object, Object, Object)

Performs additional custom processes before setting a value in the DictionaryBase instance.

System_CAPS_protmethodOnSetComplete(Object, Object, Object)

Performs additional custom processes after setting a value in the DictionaryBase instance.

System_CAPS_protmethodOnValidate(Object, Object)

Performs additional custom processes when validating the element with the specified key and value.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Add(Object, Object)

Adds an element with the specified key and value into the DictionaryBase.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Contains(Object)

Determines whether the DictionaryBase contains a specific key.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Remove(Object)

Removes the element with the specified key from the DictionaryBase.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an IEnumerator that iterates through the DictionaryBase.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

Gets a value indicating whether access to a DictionaryBase object is synchronized (thread safe).

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

Gets an object that can be used to synchronize access to a DictionaryBase object.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.IsFixedSize

Gets a value indicating whether a DictionaryBase object has a fixed size.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.IsReadOnly

Gets a value indicating whether a DictionaryBase object is read-only.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.Item(Object)

Gets or sets the value associated with the specified key.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.Keys

Gets an ICollection object containing the keys in the DictionaryBase object.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.Values

Gets an ICollection object containing the values in the DictionaryBase object.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<'TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<'TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

The foreach statement of the C# language (for each in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the DictionaryBase is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is DictionaryEntry.

The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.

System_CAPS_noteNote

Because keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparisons using the Equals method.

Notes to Implementers:

This base class is provided to make it easier for implementers to create a strongly typed custom collection. Implementers are encouraged to extend this base class instead of creating their own.

Members of this base class are protected and are intended to be used through a derived class only.

The following code example implements the DictionaryBase class and uses that implementation to create a dictionary of String keys and values that have a Length of 5 characters or less.

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1

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 DictionaryBase, but derived classes can create their own synchronized versions of the DictionaryBase 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.

Return to top
Show: