Class IDictionaryExtensions
Inheritance
IDictionaryExtensions
Assembly: Recore.dll
Syntax
public static class IDictionaryExtensions
Methods
|
Improve this Doc
View Source
AddRange<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>)
Adds all elements of the specified collection to the IDictionary<TKey,TValue>.
Existing elements are overwritten if there are duplicates.
Declaration
public static void AddRange<TKey, TValue>(this IDictionary<TKey, TValue> dict, IEnumerable<KeyValuePair<TKey, TValue>> collection)
Parameters
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
|
Improve this Doc
View Source
Append<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Declaration
public static IDictionary<TKey, TValue> Append<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, TValue value)
Parameters
Type |
Name |
Description |
IDictionary<TKey, TValue> |
dict |
|
TKey |
key |
|
TValue |
value |
|
Returns
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
|
Improve this Doc
View Source
GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Adds a key/value pair to the IDictionary<TKey,TValue> if the key does not already exist.
Returns the new value, or the existing value if the key already exists.
Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, TValue value)
Parameters
Type |
Name |
Description |
IDictionary<TKey, TValue> |
dict |
The dictionary to be operated on.
|
TKey |
key |
The key of the element to add.
|
TValue |
value |
The value to be added, if the key does not already exist.
|
Returns
Type |
Description |
TValue |
The value for the key.
This will be either the existing value for the key if the key is already in the dictionary, or the new value if the key was not in the dictionary.
|
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
|
Improve this Doc
View Source
GetValueOrDefault<TKey, TValue>(IDictionary<TKey, TValue>, TKey)
Gets the value that is associated with the specific key or the default value for the type TValue
.
Declaration
public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key)
Parameters
Type |
Name |
Description |
IDictionary<TKey, TValue> |
dict |
|
TKey |
key |
|
Returns
Type Parameters
Name |
Description |
TKey |
|
TValue |
|