Basically i'm creating a method that randomises a number then either returns 0 or the random value. (Depending upon if an array already has that value stored in it). There's currently 2 problems. Not all paths return a value. And the last part of my loop (i++) is unreachable. Any help would be great. Also heres the array that i created for the randomiser:
int[] arr = new int[4];
Heres the method:
public int UniqueRandomiser()
{
Random rnd = new Random();
int j = rnd.Next(1, 4);
for (int i = 0; i < 4; i++)
{
if (rand1[i] == j)
{
return 0;
}
else
{
return j;
}
}
}
Aucun commentaire:
Enregistrer un commentaire