Hi I have following collection
List<List<string>> Test_List = new List<List<string>>();
List<string> a = new List<string> { "1", "2", "1", "1", "3" };
List<string> b = new List<string>{ "11", "12", "11", "11", "13" };
List<string> c = new List<string>{ "21", "22", "21", "21", "23" };
List<string> d = new List<string> { "31", "32", "31", "31", "33" };
Test_List.Add(a);
Test_List.Add(b);
Test_List.Add(c);
Test_List.Add(d);
I want to get a new list that would contain a value repeated highest time in each element of Test_list for e.g. In above case a,b,c,d are element of Test_list, we see 1 has repeated highest time in a, like wise 11 in b, 21 in c and 31 in d.
I want to get a new list or array that would contain 1,11,21,31 in it. I want Linq solution without any loop.
I tried with
var res = Test_List.Select(n=>n).Select(l=>l).GroupBy(m => m).Select(g => new { count = g.Count(), value = g.Key }).OrderByDescending(u=> u.count).Select(h=>h.value).ToArray();
But above code did not work for me.
Thanks