Skip to content

Commit 71a222b

Browse files
committed
Add deconstruct for KeyValuePair
1 parent a1cbce6 commit 71a222b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#nullable enable
2+
namespace System.Collections.Generic;
3+
4+
#if NETSTANDARD2_1 || NETCOREAPP3_0 || NETCOREAPP3_1 || NET5_0_OR_GREATER
5+
#else
6+
/// <summary>
7+
/// Provide extension methods for <see cref="KeyValuePair{TKey,TValue}"/>.
8+
/// </summary>
9+
#if USE_PUBLIC_LATEST_CSHARP_FEATURES
10+
public
11+
#else
12+
internal
13+
#endif
14+
static class DotNetCampusLatestCSharpFeaturesKeyValuePairExtensions
15+
{
16+
internal static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value)
17+
where TKey : notnull
18+
{
19+
key = pair.Key;
20+
value = pair.Value;
21+
}
22+
}
23+
#endif

0 commit comments

Comments
 (0)