Find first empty "slot" in array

I am trying to make a function (in C#) that will return the first “empty” slot in an array.
Lets pretend I have an array that looks like this:

testarray[0] = Vector3(7,4,2);
testarray[1] = Vector3(9,12,5);
testarray[2] = Vector3(6,15,1);
testarray[3] = Vector3(0,0,0);
testarray[4] = Vector3(0,0,0);
testarray[5] = Vector3(13,8,5);
//...

In this example, the function would return 3, because 3 is the first time testarray contains an “empty” Vector3.

My attempts involve a for loop, but I still can’t get it to work. Ill post my code so far, but if anyone has any other ideas, please help.

int FindFirst(Vector3[] array)
{	
	for (int i = 0; i <= thearraylength; i++)
	{
	     if (array *== new Vector3(0f,0f,0f))*
  •   {*
    
  •   return i;*
    
  •   break;*
    
  •   }*
    
  • }*
    }

Don’t use for loops, just use IndexOf:

int firstEmpty = System.Array.IndexOf (testarray, Vector3.zero);

Wow, how embarrassing. After 3 hours of trying to figure this out, I post a question. Then 5 minutes later, I solve it by myself. I solved it, and becuase I don’t think it is possible to delete this post, I might as well show my answer. As it turns out, I was really close.

int FindFirst(Vector3[] array)
{   
    for (int i = 0; i <= thearraylength; i++)
    {
         if (array *== new Vector3(0f,0f,0f))*

{
return i;
break;
}
}
return -1;
}
This function will return the first location in the array of Vector3(0,0,0). If it is not found, it will return -1.
edit- After looking at Erich5h’s answer, he has a much easier, and probably faster solution. Thank you Eric5h5.

Try using this as your equality test:
array*.Equals(Vector3.zero)*