public interface IDictionary : ICollection, IEnumerable
This type implements ICollection and IEnumerable.
mscorlib
BCL
Implemented by classes that support collections of associated keys and values (i.e. dictionaries).
[Note: Each key-value pair must have a unique non-null key, but the value of an association can be any object reference, including a null reference. The IDictionary interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.IDictionary implementations fall into three categories: read-only, fixed-size, variable-size. A read-only implementation cannot be modified. A fixed-size implementation does not allow the addition or removal of elements, but it allows the modification of existing elements. A variable-size implementation allows the addition, removal and modification of elements.
]
DefaultMemberAttribute("Item")
System.Collections Namespace
IDictionary Methods
IDictionary.Add Method
IDictionary.Clear Method
IDictionary.Contains Method
IDictionary.GetEnumerator Method
IDictionary.Remove Method
IDictionary Properties
IDictionary.IsFixedSize Property
IDictionary.IsReadOnly Property
IDictionary.Item Property
IDictionary.Keys Property
IDictionary.Values Property
void Add(object key, object value);
Adds an entry with the provided key and value to the current instance.
- key
- The Object to use as the key of the entry to add.
- value
- The Object to use as the value of the entry to add.
Exception Type Condition ArgumentNullException key is null
.
ArgumentException An entry with the same key already exists in the current instance.
NotSupportedException The current instance is read-only or has a fixed size.
If the specified key already exists in the current instance, this method throws a ArgumentException exception but does not modify the associated value.[Behaviors: As described above.]
System.Collections.IDictionary Interface, System.Collections Namespace
void Clear();
Removes all key and value pairs from the current instance.
Exception Type Condition NotSupportedException The IDictionary is read-only.
[Behaviors: As described above.]
System.Collections.IDictionary Interface, System.Collections Namespace
bool Contains(object key);
Determines whether the current instance contains an entry with the specified key.
- key
- The key to locate in the IDictionary.
true
if the IDictionary contains an entry with the key; otherwise,false
.
Exception Type Condition ArgumentNullException key is null
.
[Behaviors: As described above.]
System.Collections.IDictionary Interface, System.Collections Namespace
IDictionaryEnumerator GetEnumerator();
Returns a IDictionaryEnumerator for the current instance.
A IDictionaryEnumerator for the current instance.
[Note: For detailed information regarding the use of an enumerator, see IEnumerator.]
[Behaviors: As described above.]
System.Collections.IDictionary Interface, System.Collections Namespace
void Remove(object key);
Removes the entry with the specified key from the current instance.
- key
- The key of the entry to remove.
Exception Type Condition ArgumentNullException key is null
.NotSupportedException The current instance is read-only or has a fixed size.
[Behaviors: If key is not found in the current instance, no exception is thrown and the current instance remains unchanged.]
System.Collections.IDictionary Interface, System.Collections Namespace
bool IsFixedSize { get; }
Gets a value indicating whether the current instance has a fixed size.
true
if the current instance has a fixed size; otherwise,false
.
This property is read-only.[Note: A collection with a fixed size does not allow the addition or removal of elements, but does allow the modification of existing elements.]
[Behaviors: As described above.]
[Default: The default of this property is
false
.]
[Overrides: Override this method, setting the value as
true
, to prevent the addition and removal of the elements in the current instance.]
System.Collections.IDictionary Interface, System.Collections Namespace
bool IsReadOnly { get; }
Gets a value indicating whether the current instance is read-only.
true
if the current instance is read-only; otherwise,false
.
This property is read-only.[Note: A collection that is read-only does not allow the addition, removal, or modification of elements.]
[Behaviors: As described above.]
[Default: The default of this property is
false
.]
[Overrides: Override this method, setting the value as
true
, to prevent the addition, removal, and modification of the elements in the current instance.]
System.Collections.IDictionary Interface, System.Collections Namespace
object this[object key] { get; set; }
Gets or sets the element in the current instance that is associated with the specified key.
- key
- The key of the element to get or set.
The element with the specified key.
Exception Type Condition ArgumentNullException key is null
.
NotSupportedException The property is set and the current instance is read-only. The property is set, key does not exist in the collection, and the current instance has a fixed size.
[Note: This property provides the ability to access a specific element in the collection by using the following syntax:myCollection[index]
.]
[Behaviors: 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.
]
System.Collections.IDictionary Interface, System.Collections Namespace
ICollection Keys { get; }
Gets a ICollection containing the keys of the current instance.
A ICollection containing the keys of the current instance.
This property is read-only.[Behaviors: As described above.]
System.Collections.IDictionary Interface, System.Collections Namespace
ICollection Values { get; }
Gets a ICollection containing the values in the current instance.
A ICollection containing the values in the current instance.
This property is read-only.[Behaviors: As described above.]
System.Collections.IDictionary Interface, System.Collections Namespace