5
Answers

Check for Repetition in Array with foreach loop

Keith

Keith

17y
5k
1

I'm writing a program that could store 100 customer ID in an array.
Using foreach loop to check, If same ID exist more than 3 times, it will prompt for error.
Can anyone please help me with this, thanks;

            int[] Cid = new int[5];

            for (int i = 0; i < 100; i++)
            {
                Console.Write("Customer ID: ");
                Cid[i] = int.Parse(Console.ReadLine());

                foreach(int d in Cid)
                {
                    if (??? Cid in array more than 3 times ???)
   Console.WriteLine("YOU HAVE EXCEEDED NUMBER OF ID");
                       
                }
            }

Answers (5)