So im making a program for college in which i must write a program that will store names into an array.
As a new name is entered it will be added to the end of the array. The user can keep adding names until they enter the dummy value ‘exit’
Once this has been done the program will display any duplicate names.

E.g.:

```
Enter name: Bill
Enter name: Mary
Enter name: Anisha
Enter name: Mary
Enter name: exit
Mary is a duplicate.

```

I should also try to show how many times each name was duplicated.

```
static void Main(string[] args)
{
    Console.WriteLine("This program allows you to write names to a list,");
    int i = 0;
    List<string> names = new List<string>();

    string name = " ";
    Console.WriteLine("Enter names then press enter to add them to the list of names! if you wish to exit simple type exit.");
    while (name.ToLower() != "exit")
    {
        Console.WriteLine("Enter Name: ");
        name = Console.ReadLine();
        names.Add(name);
        i++;        
    }

    string[] nameArray = names.ToArray();

    for(int z = 0;z <nameArray.Length;z++)
    {
        for (int y = z + 1; nameArray[y] == nameArray[z]; y++)
        {
            Console.WriteLine("The name: "+ nameArray[y]+" is a duplicate.");
        }
    }

    Console.ReadLine();      
}

```

This is my code but it crashes when I compare the names. It gives me one duplicate name and no others. and then crashes. I think it is relative to the second `for loop` but please could someone run this and help me out?