Represents a collection of key/value pairs that are sorted according to the key. This interface is a generalization of a dictionary that maps keys to values.
The keys in a System.Collections.Generic.IDictionary<TKey, TValue>
cannot be null
references, although unmanaged types can be keys.
The values can be null
references for reference types.
public interface IDictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, System.Collections.IEnumerable
The IDictionary<TKey, TValue>
interface represents a collection that contains keys and values.
For a list of the actual members of the IDictionary<TKey, TValue>
interface, see Members.
The IDictionary<TKey, TValue>
interface is the base interface for all generic dictionary classes.
The IDictionary<TKey, TValue>
interface requires that the TKey
type parameter be a reference type or a value type that supports equality comparison.
IsFixedSize
bool IsFixedSize { get; }
Gets a value indicating whether the dictionary has a fixed size.
IsReadOnly
bool IsReadOnly { get; }
Gets a value indicating whether the dictionary is read-only.
Keys
ICollection<TKey> Keys { get; }
Gets an ICollection<TKey> that contains the keys of the dictionary.
Values
ICollection<TValue> Values { get; }
Gets an ICollection<TValue> that contains the values of the dictionary.
Item[TKey key]
TValue Item[TKey key] { get; set; }
Gets or sets the element with the specified key.
Add(TKey key, TValue value)
void Add(TKey key, TValue value)
TKey
TValue
key
is null
.ContainsKey(TKey key)
bool ContainsKey(TKey key)
TKey
true
if the dictionary contains an element with the specified key; otherwise, false
.
Remove(TKey key)
bool Remove(TKey key)
TKey
true
if the element is successfully removed; otherwise, false
. If the dictionary does not contain an element with the specified key, the method does nothing.
TryGetValue(TKey key, out TValue value)
bool TryGetValue(TKey key, out TValue value)
TKey
TValue
(out)true
if the dictionary contains an element with the specified key; otherwise, false
.