A
A
alexoka2016-06-04 13:30:52
Programming
alexoka, 2016-06-04 13:30:52

Gentlemen, how to return the result of processing in this C # + linq snippet?

var a = new[] { 11, 11, 23, 23, 23, 23, 23, 44, 88, 88 };
var g = a
   .GroupBy(i => i) // сгруппировали
   .Select(i => i.First()) // взяли первый элемент группы
   .OrderByDescending(i => i) // отсортировали по убыванию
   .ToList();
 
var count = g.Count;

should come back something like
11 (2)
23 (5)
44 (1)
88 (2)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#algooptimize #bottize, 2016-06-04
@alexoka

I.first() buried the task.

A
alexoka, 2016-06-04
@alexoka

just get the number + the amount of the number

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question