Class KeyValuePairExtensions
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Provides extensions for the KeyValuePair<TKey, TValue> struct.
public static class KeyValuePairExtensions
- Inheritance
-
KeyValuePairExtensions
- Inherited Members
Methods
WithKey<TKey, TValue, TNewKey>(KeyValuePair<TKey, TValue>, TNewKey)
Creates a new KeyValuePair<TKey, TValue> from the given existing one, but with a different key.
public static KeyValuePair<TNewKey, TValue> WithKey<TKey, TValue, TNewKey>(this KeyValuePair<TKey, TValue> kvp, TNewKey key)
Parameters
kvpKeyValuePair<TKey, TValue>The given KeyValuePair<TKey, TValue>.
keyTNewKeyThe new key to use in the new KeyValuePair<TKey, TValue>.
Returns
- KeyValuePair<TNewKey, TValue>
A new KeyValuePair<TKey, TValue> instance with
keyas the key, and the value ofkvp.
Type Parameters
TKeyThe type of the key stored in the original KeyValuePair<TKey, TValue>.
TValueThe type of the value stored in the KeyValuePair<TKey, TValue>.
TNewKeyThe type of the key stored in the new KeyValuePair<TKey, TValue>.
WithValue<TKey, TValue, TNewValue>(KeyValuePair<TKey, TValue>, TNewValue)
Creates a new KeyValuePair<TKey, TValue> from the given existing one, but with a different value.
public static KeyValuePair<TKey, TNewValue> WithValue<TKey, TValue, TNewValue>(this KeyValuePair<TKey, TValue> kvp, TNewValue value)
Parameters
kvpKeyValuePair<TKey, TValue>The given KeyValuePair<TKey, TValue>.
valueTNewValueThe new value to use in the new KeyValuePair<TKey, TValue>.
Returns
- KeyValuePair<TKey, TNewValue>
A new KeyValuePair<TKey, TValue> instance with the key of
kvp, andvalueas the value.
Type Parameters
TKeyThe type of the key stored in the KeyValuePair<TKey, TValue>.
TValueThe type of the value stored in the original KeyValuePair<TKey, TValue>.
TNewValueThe type of the value stored in the new KeyValuePair<TKey, TValue>.