Created
June 29, 2020 00:01
-
-
Save bleroy/4f11eabdef608d10fbff2fcea9a1ebb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Util | |
{ | |
/// <summary> | |
/// An extension method that enables the deconstruction of dictionary entries. | |
/// </summary> | |
/// <example> | |
/// ```cs | |
/// foreach ((string key, Foo value) in someDictionaryOfFoos) | |
/// { | |
/// // Do something with `key` and `value`... | |
/// } | |
/// ``` | |
/// </example> | |
/// <param name="kvp">The key value pair to deconstruct.</param> | |
/// <param name="key">The deconstructed key.</param> | |
/// <param name="value">The deconstructed value.</param> | |
internal static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value) | |
{ | |
key = kvp.Key; | |
value = kvp.Value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment