M
mario semo
Hello,
why does the following simple collection code throws an exception on Min()
when there are more than 1 element in the Collection?
static void SLTest()
{
SortedList<ulong, ulong> lList = new SortedList<ulong, ulong>();
lList.Add(1, 0);
lList.Add(2, 0);
ulong l = lList.Min().Key;
Console.WriteLine(l);
/* (at least one element must implement IComparable ...)
Unbehandelte Ausnahme: System.ArgumentException: Mindestens ein Objekt muss
IComparable implementieren.
bei System.Collections.Comparer.Compare(Object a, Object b)
bei System.Collections.Generic.ObjectComparer`1.Compare(T x, T y)
bei System.Linq.Enumerable.Min[TSource](IEnumerable`1 source)
bei EulerDotNetProblems.EulerDotNetProblems.SLTest() in
S:\VS\Test\MS\ConsoleApplication4\ConsoleApplication4\Program
..cs:Zeile 3891.
bei EulerDotNetProblems.EulerDotNetProblems.Main(String[] args) in
S:\VS\Test\MS\ConsoleApplication4\ConsoleApplicati
on4\Program.cs:Zeile 124.
Drücken Sie eine beliebige Taste . . .
*/
}
why does the following simple collection code throws an exception on Min()
when there are more than 1 element in the Collection?
static void SLTest()
{
SortedList<ulong, ulong> lList = new SortedList<ulong, ulong>();
lList.Add(1, 0);
lList.Add(2, 0);
ulong l = lList.Min().Key;
Console.WriteLine(l);
/* (at least one element must implement IComparable ...)
Unbehandelte Ausnahme: System.ArgumentException: Mindestens ein Objekt muss
IComparable implementieren.
bei System.Collections.Comparer.Compare(Object a, Object b)
bei System.Collections.Generic.ObjectComparer`1.Compare(T x, T y)
bei System.Linq.Enumerable.Min[TSource](IEnumerable`1 source)
bei EulerDotNetProblems.EulerDotNetProblems.SLTest() in
S:\VS\Test\MS\ConsoleApplication4\ConsoleApplication4\Program
..cs:Zeile 3891.
bei EulerDotNetProblems.EulerDotNetProblems.Main(String[] args) in
S:\VS\Test\MS\ConsoleApplication4\ConsoleApplicati
on4\Program.cs:Zeile 124.
Drücken Sie eine beliebige Taste . . .
*/
}