Table of Contents

Method Deconstruct

Namespace
DisCatSharp.Common
Assembly
DisCatSharp.Common.dll

Deconstruct<TKey, TValue>(KeyValuePair<TKey, TValue>, out TKey, out TValue)

Deconstructs a Dictionary<TKey, TValue> key-value pair item ( KeyValuePair<TKey, TValue>) into 2 separate variables.

This allows for enumerating over dictionaries in foreach blocks by using a (k, v) tuple as the enumerator variable, instead of having to use a KeyValuePair<TKey, TValue> directly.

public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value)

Parameters

kvp KeyValuePair<TKey, TValue>

Key-value pair to deconstruct.

key TKey

Deconstructed key.

value TValue

Deconstructed value.

Type Parameters

TKey

Type of dictionary item key.

TValue

Type of dictionary item value.