Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barisesen/20a6e84340f2706ada27e2aca8ccc07d to your computer and use it in GitHub Desktop.
Save barisesen/20a6e84340f2706ada27e2aca8ccc07d to your computer and use it in GitHub Desktop.
using System.Linq;
static void Main(string[] args)
{
int[] array = { 10, 5, 10, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 11, 12, 12 };
var dict = new Dictionary<int, int>();
foreach (var value in array)
{
if (dict.ContainsKey(value))
dict[value]++;
else
dict[value] = 1;
}
foreach (var pair in dict)
Console.WriteLine("Value {0} occurred {1} times.", pair.Key, pair.Value);
Console.WriteLine(dict.Values.Max());
foreach (var item in dict)
{
if ( dict.Values.Max() == item.Value)
{
Console.WriteLine("This is max val {0}",item);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment