I have a SortedList from the lists, and I am interested in finding the KEY that matches the longest list (the list with the most items in it). In code, it looks like this:
var myList = new SortedList<long, List<string>>();
myList.Add(0, new List<string>());
myList[0].AddRange(new []{"a", "b", "c"});
myList.Add(8, new List<string>());
myList[8].AddRange(new []{"1", "2"});
myList.Add(23, new List<string>());
myList[23].AddRange(new []{"c", "d", "e", "f", "g"});
In the above example, the result should be "23", since this is the key that comes with the longest list.
I know how to write this with a for loop, but I think it should just be LINQ related. However, I cannot get the syntax perfectly correct! Any help is appreciated!
source
share