BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 System.Collections.ICollection System.Runtime.InteropServices.ComVisible(true)

The interface is the base interface for nongeneric collections of key/value pairs. For the generic version of this interface, see .

Each element is a key/value pair stored in a object.

Each pair must have a unique key. Implementations can vary in whether they allow the key to be null. The value can be null and does not have to be unique. The interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.

implementations fall into three categories: read-only, fixed-size, variable-size. A read-only object cannot be modified. A fixed-size object does not allow the addition or removal of elements, but does allow the modification of existing elements. A variable-size object allows the addition, removal, and modification of elements.

The foreach statement of the C# language (For Each in Visual Basic) requires the type of each element in the collection. Since each element of the object 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 . For example:

code reference: Dictionary#14

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

Represents a nongeneric collection of key/value pairs.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  is .

  An entry with the same key already exists in the current instance.

  The current instance is read-only or has a fixed size.

  You can also use the property to add new elements by setting the value of a key that does not exist in the dictionary (for example, myCollection["myNonexistentKey"] = myValue). However, if the specified key already exists in the dictionary, setting the property overwrites the old value. In contrast, the method does not modify existing elements.

  Implementations can vary in whether they allow the key to be null.

  Adds an element with the provided key and value to the object.

  The to use as the key of the element to add. The to use as the value of the element to add. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  As described above.

  The is read-only.

  Removes all elements from the object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` is .

  Implementations can vary in whether they allow the key to be null.

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether the object contains an element with the specified key.

  true if the contains an element with the key; otherwise, false.

  The key to locate in the object. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IDictionaryEnumerator

  [Visual Basic, C#]

  The foreach statement of the C# language (for each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

  Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, the property is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of .

  returns the same object until either or is called. sets to the next element.

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returned false, is undefined. To set to the first element of the collection again, you can call followed by .

  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

  Returns an object for the object.

  An object for the object.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean

  if the current instance has a fixed size; otherwise, .

  A collection with a fixed size does not allow the addition or removal of elements after the collection is created, but does allow the modification of existing elements.

  A collection with a fixed size is simply a collection with a wrapper that prevents adding and removing elements; therefore, if changes are made to the underlying collection, including the addition or removal of elements, the fixed-size collection reflects those changes.

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

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean

  if the current instance is read-only; otherwise, .

  A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created.

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

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` The key of the element to get or set.

  Gets or sets the element in the current instance that is associated with the specified key.

  The element with the specified key.

  This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

  When setting this property, if the specified key already exists in the current instance, the value is required to be replaced; otherwise, a new element is required to be created.

  is .

  The property is set and the current instance is read-only.

  The property is set, does not exist in the collection, and the current instance has a fixed size.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.ICollection

  A containing the keys of the current instance.

  The order of the keys in the returned object is unspecified, but is guaranteed to be the same order as the corresponding values in the returned by the property.

  Gets an object containing the keys of the object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` is .

  The current instance is read-only or has a fixed size.

  If the object does not contain an element with the specified key, the remains unchanged. No exception is thrown.

  Removes the element with the specified key from the object.

  The key of the element to remove. 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.ICollection

  A containing the values in the current instance.

  The order of the values in the returned object is unspecified, but is guaranteed to be the same order as the corresponding keys in the returned by the property.

  Gets an object containing the values in the object.

  0
0