Skip to content

Commit 6b3253c

Browse files
committed
Readd ToDictionary for lower .NET versions
1 parent 5291ad0 commit 6b3253c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Noggog.CSharpExt/Extensions/DictionaryExt.cs

+9
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,14 @@ private static class DictEmptyExt<TKey, TValue>
150150
where TKey : notnull
151151
{
152152
public static Dictionary<TKey, TValue> Empty = new Dictionary<TKey, TValue>();
153+
}
154+
155+
#if NET8_0_OR_GREATER
156+
#else
157+
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> keyValuePairs)
158+
where TKey : notnull
159+
{
160+
return keyValuePairs.ToDictionary(kv => kv.Key, kv => kv.Value);
153161
}
162+
#endif
154163
}

0 commit comments

Comments
 (0)