So, what I'm trying to do is to check if a letter already exists within an array, so I use a for loop and it works very well.
So if the character exists within the array, it will not add the letter you put in the input box into the array, but if it doesn't exist, then go ahead and add the letter to the array.
if (bokstav == enBokstav)
{
for (int arrIndex = 0; arrIndex < gjettet_bokstaver.Length; arrIndex++)
{
if (bokstav == gjettet_bokstaver[arrIndex])
{
MessageBox.Show("Du har allerede brukt den bokstaven");
}
}
if (bokstav != gjettet_bokstaver[array_size])
{
gjettet_bokstaver[array_size] += bokstav;
array_size++;
RiktigBokstav.Text += gjettet_bokstaver[(array_size - 1)];
}
}
So, my problem is that, if the letter exists in the array, there will come a poup box saying it's already used and it will still add a new character instead of stopping the script, sort of.
Thanks in advance :)