Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2008-02-10 06:54:55 +0300
committerMiguel de Icaza <miguel@gnome.org>2008-02-10 06:54:55 +0300
commitd99ebe3ed0d518ca4bef41af02e95ac3239109df (patch)
tree0b65d9f39f82687b617fc5ff273acacb783e6119 /mcs/class/System.Core/System.Linq/Enumerable.cs
parent2b0170253b51bbd4eb6c2283b9aa83ea561bc410 (diff)
2008-02-09 Miguel de Icaza <miguel@novell.com>
* Enumerable.cs (ToDictionary): Implement this overload. svn path=/trunk/mcs/; revision=95356
Diffstat (limited to 'mcs/class/System.Core/System.Linq/Enumerable.cs')
-rw-r--r--mcs/class/System.Core/System.Linq/Enumerable.cs13
1 files changed, 10 insertions, 3 deletions
diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs
index 9946aafcac7..2ce250ff2a6 100644
--- a/mcs/class/System.Core/System.Linq/Enumerable.cs
+++ b/mcs/class/System.Core/System.Linq/Enumerable.cs
@@ -2314,9 +2314,16 @@ namespace System.Linq
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey> (this IEnumerable<TSource> source,
Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
- throw new NotImplementedException ();
- // FIXME: compiler issue
- //return ToDictionary (source, keySelector, (a) => a, comparer);
+ Check.SourceAndKeySelector (source, keySelector);
+
+ if (comparer == null)
+ comparer = EqualityComparer<TKey>.Default;
+
+ var dict = new Dictionary<TKey, TSource> (comparer);
+ foreach (var e in source)
+ dict.Add (keySelector (e), e);
+
+ return dict;
}
#endregion