how to find empty elements in array?

Hello, I have array of moves for player and I want player to have only 4 move so I declared fixed size array: public Move moves = new Move[4];

and then I checked if there is any empty element in this array,

I wrote somthing like this:

for(int i = 0; i < moves.Length; i++) {
if(moves *== null) {*

return true;
}
return false;
}
And it returns false.

Hi,

I recommend using indentations (maybe you do, just saying) and typing “{” in new lines like so:

for (int i = 0; i < moves.Length; i++)
{
     if (moves *== null)*

{
return true;
}
return false;
}
Now its clear that you are returning false inside a loop, you want in to return false after you iterate through entire loop. In your example, you check first move and if its not null you return false, you do not check rest of the moves.