-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Collectionshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorswishlistIssue we would like to prioritize, but we can't commit we will get to it yetIssue we would like to prioritize, but we can't commit we will get to it yet
Milestone
Description
Background
C# 7 added support for deconstruction of user-defined types via a Deconstruct(out ...) method. (see it in action) It would make sense to be able to use this feature with tuple-like types such as KeyValuePair and DictionaryEntry.
Proposal
public struct KeyValuePair<TKey, TValue>
{
// BLOCKED (do not add now): [EditorBrowsable(EditorBrowsableState.Never)]
public void Deconstruct(out TKey key, out TValue value);
}
public struct DictionaryEntry
{
// BLOCKED (do not add now): [EditorBrowsable(EditorBrowsableState.Never)]
public void Deconstruct(out object key, out object value);
}Usage
public void MyDictionaryMethod()
{
var dict = new Dictionary<int, string>();
dict.Add(1, "2");
var (one, two) = dict.First();
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Collectionshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorswishlistIssue we would like to prioritize, but we can't commit we will get to it yetIssue we would like to prioritize, but we can't commit we will get to it yet