Find out max duplicate number between 1 to N numbers
You can use GroupBy to count the duplicates.

Then you should sort the result and get the first item once, instead of sorting it each time you use it:

int[] _input = new int[] {
  5, 45, 184, 594, 14, 8, 5, 184, 1841, 184, 594, 5, 78, 594, 14, 8, 18, 4, 18, 14, 8, 594
};

IGrouping&lt;int, int&gt; max =
  _input.GroupBy(n =&gt; n)
  .OrderByDescending(g =&gt; g.Count())
  .First();

Console.WriteLine(
  "Maximum number repeated is " + max.Key +
  " and it is repeated " + max.Count() + " times"
);