-
-
Save barisesen/20a6e84340f2706ada27e2aca8ccc07d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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