How do I check if an Array element has a value assigned?
This is my current code…
for (int i = 0; i <= monstersList.Length; i++)
{
Debug.Write("in loop");
if (monstersList[i] != null)
{
//do stuff with free element
}
}
…and this is my solution…
if (monstersList[i] != null)
…but it keeps throwing out the ‘out of range error’ so clearly my solution is wrong.