XDracam / unity-corelibrary

Collection of classes and extension methods that make life with Unity3D more comfortable
MIT License
15 stars 3 forks source link

Dictionary<TKey, TValue> ToDictionary(this IEnumerable<(TKey, TValue)>) #44

Open XDracam opened 5 years ago

XDracam commented 5 years ago

We want an extension methods for all enumerables of tuples, which builds a dictionary. The implementation is straight forward:

public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<(TKey, TValue)> src) => 
    src.ToDictionary(v => v.Item1, v => v.Item2);