Do I need to define comparer for values inside sortedDictionary?

46 Views Asked by At

I have sortedDictionary where key is float and value is some class i wrote. I try to use myDictionary.Max(), but I get an argument exception:

ArgumentException: At least one object must implement IComparable.
System.Collections.Comparer.Compare (System.Object a, System.Object b) (at <d6232873609549b8a045fa15811a5bd3>:0)
System.Collections.Generic.ObjectComparer`1[T].Compare (T x, T y) (at <d6232873609549b8a045fa15811a5bd3>:0)
System.Linq.Enumerable.Max[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <109e781b32ec464d8737a667de805742>:0)

Isn't it that I don't need custom comparer if I use generic as key?

0

There are 0 best solutions below