Count of Numbers in integer array

output

------------------------

1-4

2-3

3-2

4-3

//=======================


int[] array = { 1, 1, 4, 2, 1, 2, 2, 3, 3, 1, 4, 4 };


           

            SortedList<int, int> sortedInt = new SortedList<int, int>();

            int count = 0;

           


            foreach (int num in array)

            {

                if (!sortedInt.ContainsKey(num))

                {

                    count = 0;

                    for (int i = 0; i < array.Length; i++)

                    {


                        if (array[i] == num) count++;



                    }


                    sortedInt.Add(num, count);



                }

               

            }


            foreach(var item in sortedInt)

            {

                Console.WriteLine(item.Key + "-" + item.Value);

            }



            Console.ReadLine();