DictionaryBase<TKey, TValue> Class
Provides a base class for generic dictionary.
public abstract class DictionaryBase<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
Type Parameters
TKey
The type of the key.
TValue
The type of the value.
- Inheritance:
- System.
Object DictionaryBase<TKey, TValue>
- Derived
Implements
Remarks
This class is used as a base class for Built
Properties
Count
Gets the number of key/value pairs contained in the DictionaryBase<TKey, TValue>.
Property Value
- System.
Int32
The number of key/value pairs contained in the DictionaryBase<TKey, TValue>.
Item[TKey]
Gets or sets the value associated with the specified key.
Parameters
key
- TKey
The key of the value to get or set.
Property Value
- TValue
The value associated with the specified key.
Keys
Gets a collection containing the keys in the DictionaryBase<TKey, TValue>.
Property Value
- System.
Collections. <TKey>Generic. ICollection
A collection containing the keys in the DictionaryBase<TKey, TValue>.
Values
Gets a collection containing the values in the DictionaryBase<TKey, TValue>.
Property Value
- System.
Collections. <TValue>Generic. ICollection
A collection containing the values in the DictionaryBase<TKey, TValue>.
Methods
Add(TKey, TValue)
Adds the specified key and value to the DictionaryBase<TKey, TValue>.
Parameters
key
- TKey
The key of the element to add.
value
- TValue
The value of the element to add.
Clear()
Removes all keys and values from the DictionaryBase<TKey, TValue>.
ContainsKey(TKey)
Determines whether the DictionaryBase<TKey, TValue> contains the specified key.
Parameters
key
- TKey
The key to locate in the DictionaryBase<TKey, TValue>.
Returns
- System.
Boolean
true
if the DictionaryBase<TKey, TValue> contains an element with the specified key; otherwise, false
.
GetEnumerator()
Returns an enumerator that iterates through the DictionaryBase<TKey, TValue>.
Returns
- System.
Collections. <System.Generic. IEnumerator Collections. <TKey, TValue>>Generic. Key Value Pair
An enumerator that can be used to iterate through the DictionaryBase<TKey, TValue>.
Remove(TKey)
Removes the value with the specified key from the DictionaryBase<TKey, TValue>.
Parameters
key
- TKey
The key of the element to remove.
Returns
- System.
Boolean
true
if the element is successfully found and removed; otherwise, false
. This method returns false
if key is not found in the DictionaryBase<TKey, TValue>.
TryGetValue(TKey, out TValue)
Gets the value associated with the specified key.
Parameters
key
- TKey
The key of the value to get.
value
- TValue
When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value
parameter. This parameter is passed uninitialized.
Returns
- System.
Boolean
true
if the DictionaryBase<TKey, TValue> contains an element with the specified key; otherwise, false
.