Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Random rand = new Random();
int[] array = new int[100];
for (int i = 0; i < 100; i++)
{
array[i] = rand.Next(0, 30);
}
Dictionary<int, int> counts = new Dictionary<int, int>();
foreach (int num in array)
{
if (counts.ContainsKey(num))
counts[num]++;
else
counts.Add(num, 1);
}
foreach (KeyValuePair<int, int> kvp in counts)
{
Console.WriteLine("there are {0} number of {1}", kvp.Value, kvp.Key);
}
Console.ReadLine();
}
}
}