Class IDictionaryEx
Class containing some extension methods for System.Collections.Generic.IDictionary<TKey, TValue>.
Inheritance
Inherited Members
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class IDictionaryEx
Methods
| Improve this Doc View SourceAddIfNotContainsKey<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Adds the given key value pair to the dictionary, if it not already contains the key.
Declaration
public static bool AddIfNotContainsKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to which the item should get added. |
| TKey | key | The key. |
| TValue | value | The value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the item was added to the dictionary, otherwise false. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | the type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The key can not be null. |
AddIfNotContainsKey<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TKey, TValue>)
Adds the key and value returned by the given factory to the dictionary, if it not already contains the key.
Declaration
public static bool AddIfNotContainsKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> valueFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to which the item should get added. |
| TKey | key | The key. |
| System.Func<T, TResult><TKey, TValue> | valueFactory | The factory which creates the value for the key value pair. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the item was added to the dictionary, otherwise false. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | the type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The key can not be null. |
| System.ArgumentNullException | The factory can not be null. |
AddIfNotContainsKey<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TValue>)
Adds the key and value returned by the given factory to the dictionary, if it not already contains the key.
Declaration
public static bool AddIfNotContainsKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TValue> valueFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to which the item should get added. |
| TKey | key | The key. |
| System.Func<TResult><TValue> | valueFactory | The factory which creates the value for the key value pair. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the item was added to the dictionary, otherwise false. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | the type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The key can not be null. |
| System.ArgumentNullException | The factory can not be null. |
AddIfNotContainsKey<TKey, TValue>(IDictionary<TKey, TValue>, KeyValuePair<TKey, TValue>)
Adds the given key value pair to the dictionary, if it not already contains the key.
Declaration
public static bool AddIfNotContainsKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, KeyValuePair<TKey, TValue> keyValuePair)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to which the item should get added. |
| System.Collections.Generic.KeyValuePair<TKey, TValue><TKey, TValue> | keyValuePair | The KeyValuePair to add. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the item was added to the dictionary, otherwise false. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | the type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | dictionary can not be null. |
| System.ArgumentNullException | key can not be null. |
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Adds the given key value pair to the dictionary, if the key does not already exist, otherwise updates the value of the given key in the dictionary.
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to work on. |
| TKey | key | The key to be added or whose value should be updated. |
| TValue | value | The value to be added or updated. |
Returns
| Type | Description |
|---|---|
| TValue | The new value for the key. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | dictionary can not be null. |
| System.ArgumentNullException | key can not be null. |
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TKey, TValue>)
Adds the given key and the value created by the value factory to the dictionary, if the key does not already exist, otherwise updates the value of the given key in the dictionary.
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> valueFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The Dictionary to work on. |
| TKey | key | The Key. |
| System.Func<T, TResult><TKey, TValue> | valueFactory | The factory which creates the value for the key value pair. |
Returns
| Type | Description |
|---|---|
| TValue | The new value for the key. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TValue>)
Adds the given key and the value created by the value factory to the dictionary, if the key does not already exist, otherwise updates the value of the given key in the dictionary.
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TValue> valueFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The Dictionary to work on. |
| TKey | key | The Key. |
| System.Func<TResult><TValue> | valueFactory | The factory which creates the value for the key value pair. |
Returns
| Type | Description |
|---|---|
| TValue | The new value for the key. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | dictionary can not be null. |
| System.ArgumentNullException | key can not be null. |
| System.ArgumentNullException | valueFactory can not be null. |
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, KeyValuePair<TKey, TValue>)
Adds the given key value pair to the dictionary, if the key does not already exist, otherwise updates the value of the given key in the dictionary.
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, KeyValuePair<TKey, TValue> keyValuePair)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to work on. |
| System.Collections.Generic.KeyValuePair<TKey, TValue><TKey, TValue> | keyValuePair | The KeyValuePair to be added or updated. |
Returns
| Type | Description |
|---|---|
| TValue | The new value for the key. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | dictionary can not be null. |
| System.ArgumentNullException | key can not be null. |
AddRange<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)
Adds the values of the given dictionary to the dictionary.
Declaration
public static IDictionary<TKey, TValue> AddRange<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IDictionary<TKey, TValue> otherDictionary)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to add the items to. |
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | otherDictionary | The dictionary containing the items to add. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | Returns the dictionary containing all the items.. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the keys. |
| TValue | The type of the values. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The other dictionary can not be null. |
ConcatAllToDictionary<TValue, TKey>(IDictionary<TValue, TKey>, IDictionary<TValue, TKey>[])
Concatenates the given sequences.
Declaration
public static IDictionary<TValue, TKey> ConcatAllToDictionary<TValue, TKey>(this IDictionary<TValue, TKey> dictionary, params IDictionary<TValue, TKey>[] dictionaries)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | dictionary | The first dictionary to concatenate. |
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey>[] | dictionaries | The other dictionaries to concatenate. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | Returns an System.Collections.Generic.IDictionary<TKey, TValue> that contains the concatenated elements of the given sequences. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the values. |
| TKey | The type of the keys. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | dictionary can not be null. |
| System.ArgumentNullException | dictionaries can not be null. |
| System.ArgumentException | An element with the same key already exists in the dictionary. |
ConcatAllToDictionarySafe<TValue, TKey>(IDictionary<TValue, TKey>, IDictionary<TValue, TKey>[])
Concatenates the given sequences in a safe manner.
Declaration
public static IDictionary<TValue, TKey> ConcatAllToDictionarySafe<TValue, TKey>(this IDictionary<TValue, TKey> dictionary, params IDictionary<TValue, TKey>[] dictionaries)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | dictionary | The first dictionary to concatenate. |
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey>[] | dictionaries | The other dictionaries to concatenate. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | Returns an System.Collections.Generic.IDictionary<TKey, TValue> that contains the concatenated elements of the given sequences. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the values. |
| TKey | The type of the keys. |
Remarks
Duplicated key are getting removed.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | dictionary can not be null. |
| System.ArgumentNullException | dictionaries can not be null. |
ConcatToDictionary<TValue, TKey>(IEnumerable<KeyValuePair<TValue, TKey>>, IEnumerable<KeyValuePair<TValue, TKey>>)
Concatenates the given sequences.
Declaration
public static IDictionary<TValue, TKey> ConcatToDictionary<TValue, TKey>(this IEnumerable<KeyValuePair<TValue, TKey>> first, IEnumerable<KeyValuePair<TValue, TKey>> second)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T><System.Collections.Generic.KeyValuePair<TKey, TValue><TValue, TKey>> | first | The first sequence to concatenate. |
| System.Collections.Generic.IEnumerable<T><System.Collections.Generic.KeyValuePair<TKey, TValue><TValue, TKey>> | second | The second sequence to concatenate. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | Returns an System.Collections.Generic.IDictionary<TKey, TValue> that contains the concatenated elements of the two input sequences. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the values. |
| TKey | The type of the keys. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | first can not be null. |
| System.ArgumentNullException | second can not be null. |
| System.ArgumentException | An element with the same key already exists in the dictionary. |
ConcatToDictionarySafe<TValue, TKey>(IEnumerable<KeyValuePair<TValue, TKey>>, IEnumerable<KeyValuePair<TValue, TKey>>)
Concatenates the given sequences in a safe manner.
Declaration
public static IDictionary<TValue, TKey> ConcatToDictionarySafe<TValue, TKey>(this IEnumerable<KeyValuePair<TValue, TKey>> first, IEnumerable<KeyValuePair<TValue, TKey>> second)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T><System.Collections.Generic.KeyValuePair<TKey, TValue><TValue, TKey>> | first | The first sequence to concatenate. |
| System.Collections.Generic.IEnumerable<T><System.Collections.Generic.KeyValuePair<TKey, TValue><TValue, TKey>> | second | The second sequence to concatenate. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | Returns an System.Collections.Generic.IDictionary<TKey, TValue> that contains the concatenated elements of the two input sequences. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the values. |
| TKey | The type of the keys. |
Remarks
Duplicated key are getting removed.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | first can not be null. |
| System.ArgumentNullException | second can not be null. |
ContainsAllKey<TKey, TValue>(IDictionary<TKey, TValue>, TKey[])
Checks if the dictionary contains all given keys.
Declaration
public static bool ContainsAllKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, params TKey[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The Dictionary to act on. |
| TKey[] | keys | A list of keys. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the dictionary contains all keys. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The keys can not be null. |
ContainsAllKey<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<TKey>)
Checks if the dictionary contains all given keys.
Declaration
public static bool ContainsAllKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IEnumerable<TKey> keys)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The Dictionary to act on. |
| System.Collections.Generic.IEnumerable<T><TKey> | keys | A list of keys. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the dictionary contains all keys. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The keys can not be null. |
ContainsAnyKey<TKey, TValue>(IDictionary<TKey, TValue>, TKey[])
Checks if the dictionary contains any of the given keys.
Declaration
public static bool ContainsAnyKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, params TKey[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to act on. |
| TKey[] | keys | A list of keys. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the dictionary contains any of the given keys, otherwise false. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The keys can not be null. |
ContainsAnyKey<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<TKey>)
Checks if the dictionary contains any of the given keys.
Declaration
public static bool ContainsAnyKey<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IEnumerable<TKey> keys)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to act on. |
| System.Collections.Generic.IEnumerable<T><TKey> | keys | A list of keys. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the dictionary contains any of the given keys, otherwise false. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The keys can not be null. |
GetAllKeys<TKey, TValue>(IDictionary<TKey, TValue>)
Gets all keys of the given dictionary.
Declaration
public static IEnumerable<TKey> GetAllKeys<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The Dictionary to act on. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><TKey> | Returns all keys of the given dictionary. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
GetAllKeysAsList<TKey, TValue>(IDictionary<TKey, TValue>)
Gets all keys of the given dictionary as list.
Declaration
public static List<TKey> GetAllKeysAsList<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The Dictionary to act on. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<T><TKey> | Returns all keys of the given dictionary as list. |
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key. |
| TValue | Type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Adds the given key value pair to the dictionary if the key does not already exist.
Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to act 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 | Returns 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 | The type of the key. |
| TValue | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The key can not be null. |
GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TKey, TValue>)
Adds the key value pair to the dictionary, by using the specified function, if the key does not already exist.
Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> valueFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to act on. |
| TKey | key | The key of the element to add. |
| System.Func<T, TResult><TKey, TValue> | valueFactory | TThe function used to generate a value for the key. |
Returns
| Type | Description |
|---|---|
| TValue | Returns 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 for the key as returned by value factory if the key was not in the dictionary. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The factory can not be null. |
| System.ArgumentNullException | The key can not be null. |
GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TValue>)
Adds the key value pair to the dictionary, by using the specified function, if the key does not already exist.
Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TValue> valueFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to act on. |
| TKey | key | The key of the element to add. |
| System.Func<TResult><TValue> | valueFactory | TThe function used to generate a value for the key. |
Returns
| Type | Description |
|---|---|
| TValue | Returns 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 for the key as returned by value factory if the key was not in the dictionary. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The factory can not be null. |
| System.ArgumentNullException | The key can not be null. |
GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, KeyValuePair<TKey, TValue>)
Adds the given key value pair to the dictionary if the key does not already exist.
Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, KeyValuePair<TKey, TValue> keyValuePair)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TKey, TValue> | dictionary | The dictionary to act on. |
| System.Collections.Generic.KeyValuePair<TKey, TValue><TKey, TValue> | keyValuePair | The key value pair to add or get. |
Returns
| Type | Description |
|---|---|
| TValue | Returns 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 | The type of the key. |
| TValue | The type of the value. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The dictionary can not be null. |
| System.ArgumentNullException | The key can not be null. |
StringJoin<TValue, TKey>(IDictionary<TValue, TKey>, String, String)
Concatenates all the elements of a first using the specified separator between each element.
Declaration
public static string StringJoin<TValue, TKey>(this IDictionary<TValue, TKey> dictionary, string keyValueSeparator = "=", string separator = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><TValue, TKey> | dictionary | A first that contains the elements to concatenate. |
| System.String | keyValueSeparator | The string to use as a separator between each key and value. |
| System.String | separator | The string to use as a separator. The separator is included in the returned string only if the given first has more than one item. |
Returns
| Type | Description |
|---|---|
| System.String | A string that consists of the elements in the first delimited by the separator string. If the given first is empty, the method returns String.Empty. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the values in the first. |
| TKey | The type of the keys in the first. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The first can not be null. |