String[] _numbers = { "2", "1", "3", "2", "4", "6", "2", "1", "4", "6", "6", "4", "8", "1", "3", "8" };
var _query2 = from n in _numbers
group n by n into g
select new
{
number = g.Key,
count = g.Count()
};
var _MaxCount = _query2.Max(a => a.count);
var mostOccurednumber = _query2
.Where(g => g.count == _MaxCount)
.Select(g => g.number);
Saturday, April 26, 2014
Most Occurred Number in Integer Array using Linq using C#
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment