- Home /
Question by
Tofudude624 · Apr 22, 2012 at 11:52 PM ·
arraynull
Checking for null elements in a subset?
Hey. If I have an array of objects that has elements, how can I check to see if elements 3-30 are null or not? Thanks
Comment
Answer by syclamoth · Apr 23, 2012 at 01:14 AM
foreach(<ElementType> element in array)
{
if(element == null)
{
// It's null!
}
}
for(int i = 0; i < array.Length; ++i)
{
if(array[i] == null)
{
// Element 'i' is null!
}
}
And so on. If you're using Javascript for some reason, the syntax changes a little-
for(var element : <ElementType> in array)
{
if(element == null)
{
// and so on
}
}
Your answer
Follow this Question
Related Questions
how to check for GameObject is null in array with random 1 Answer
Checking array fails each time. But change anything and resave and it works until unity closes...... 1 Answer
Access if there are items in an array? 2 Answers
Simple Looping drag and drop game 1 Answer
Removing null object from array in unity 0 Answers