Last active
May 29, 2016 03:36
-
-
Save jmsevold/be2e51d1d76d8b7e221fd362c3f2b588 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.Collections.Generic; | |
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
int[] nums = new int[] {1,1,1,2,2,3}; | |
Dictionary<string,int> numCount = new Dictionary<string,int>(); | |
foreach(int num in nums) | |
{ | |
string numKey = num.ToString(); | |
if(numCount.ContainsKey(numKey)) | |
{ | |
numCount[numKey] += 1; | |
} | |
else | |
{ | |
numCount.Add(numKey,1); | |
} | |
} | |
foreach(KeyValuePair<string,int> pair in numCount) | |
{ | |
Console.WriteLine("{0}, {1}", pair.Key, pair.Value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment