Extension methods for KeyValuePair<TKey, TValue>.
Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
See Also: Inherited members from object.
⊟ Public Methods
staticAggregate<TKey,TValue,TResult> (this KeyValuePair<TKey, TValue>, Func<TKey, TValue, TResult>) : TResult Applies an accumulator to a KeyValuePair<TKey, TValue>, converting the KeyValuePair<TKey, TValue> into a different value. staticToTuple<TKey,TValue> (this KeyValuePair<TKey, TValue>) : Cadenza.Tuple<TKey, TValue> Converts a KeyValuePair<TKey, TValue> into a Cadenza.Tuple<TKey, TValue>.
⊟ Aggregate<TKey,TValue,TResult> Generic Method
Applies an accumulator to a KeyValuePair<TKey, TValue>, converting the KeyValuePair<TKey, TValue> into a different value.
public static TResult Aggregate<TKey, TValue, TResult> (this KeyValuePair<TKey, TValue> self, Func<TKey, TValue, TResult> func)⊟ Type Parameters
- TKey
- The type of the key.
- TValue
- Type type of the value.
- TResult
- The type to accumulator value.
⊟ Parameters
- self
- A KeyValuePair<TKey, TValue>. instance to convert into a TResult.
- func
- A Func<TKey, TValue, TResult> which is invoked to convert the KeyValuePair<TKey, TValue> into a TResult.
⊟ Returns
A TResult, which is the return value of func.⊟ Exceptions
Type Reason ArgumentNullException Documentation for this section has not yet been entered. ⊟ Remarks
This is useful primarily to avoid an unseemly temporary (or to more easily use KeyValuePair<TKey, TValue>s within expressions).
C# Example var dict = new Dictionary<int, int> { { 1, 1 }, { 2, 4 }, { 3, 9 }, }; string entries = dict .Select( e => /* e is a KeyValuePair<int,int> */ e.Aggregate( (k, v) => string.Format("({0},{1})", k, v) ) ) .Implode("|"); // entries contains "(1,1)|(2,4)|(3,9)"⊟ Requirements
Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
⊟ ToTuple<TKey,TValue> Generic Method
Converts a KeyValuePair<TKey, TValue> into a Cadenza.Tuple<TKey, TValue>.
public static Cadenza.Tuple<TKey, TValue> ToTuple<TKey, TValue> (this KeyValuePair<TKey, TValue> self)⊟ See Also
⊟ Type Parameters
- TKey
- The type of the key.
- TValue
- The type of the value.
⊟ Parameters
- self
- A KeyValuePair<TKey, TValue>. to convert into a Cadenza.Tuple<TKey, TValue>.
⊟ Returns
A Cadenza.Tuple<TKey, TValue> struct.⊟ Remarks
The value of the returned Cadenza.Tuple`2._1 property is copied from KeyValuePair`2.Key and the value of the returned Cadenza.Tuple`2._2 is copied from KeyValuePair`2.Value.
C# Example KeyValuePair<string, int> kvp = new KeyValuePair<string, int> ("s", 1); Tuple<string, int> tuple = kvp.ToTuple (); // tuple._1 == "s", tuple._2 == 1⊟ Requirements
Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0