I have been searching for an answers to my problem but I can't find any solutions. I writing a program where the user enter name, last name, and social number for five students. When that's done a random number will get handed to each of the five students the user has typed in. But the problem is that two students can not have the same random number. I know with 1-10000 the chances is low, but this is my task.
This is my code where I have tried to fix the problem but I can't get it to work.
while (antal != ggr)
{
    string name = Interaction.InputBox("Write name: ");
    string lastname = Interaction.InputBox("Write last name: ");
    string socialnr = Interaction.InputBox("Write social number: ");
    while (a != false)
    {
        foreach (int item in uniqNum)
        {
            if (item == _rnd)
            {
                a = true;
            }
            else
            {
                _rnd = rnd.Next(1, 10000);
                uniqNum.Add(_rnd);
                a = false;
            }
        }
    }
    ggr++;
    _Studens.Add(new student(name, lastname, socialnr, _rnd));
}