Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. .GroupBy(..., numbersGroup => numbersGroup.Key),
  2. .OrderByDescending(supergroup => supergroup.Key)
  3. .First()
  4.  
  5. int[] numbers1 = { 1, 2, 3, 3, 2, 4 };
  6.  
  7. // First in GroupBy(x => x) I group all numbers within the array (remove all duplicates too?), now my array looks like this [1,2,3,4].
  8. int[] result = numbers1.GroupBy(x => x)
  9. // In GroupBy(numbersGroup => numbersGroup.Count()) I collect all the different amount of occurrences withing the array, that would be 1 (1, 4) and 2 for (2, 4) so my array should look like this now [1, 2].
  10. // Now this is where things get out of hand, what happens at the rest of it? I have tried for 4 hours now and can't figure it out. What exactly happens in numbersGroup => numbersGroup.Key? .OrderByDescending(supergroup => supergroup.Key)?
  11. .GroupBy(numbersGroup => numbersGroup.Count(), numbersGroup => numbersGroup.Key)
  12. .OrderByDescending(supergroup => supergroup.Key)
  13. .First()
  14. .ToArray();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement