Stack Exchange
How to find a Vector3 that is 0,0,0 in an array
This code is working:
/* create empty list */
Vector3[] vertices = new Vector3[50];
/* add only one element */
vertices[0] = new Vector3(0, 1, 2);

/* test with non-null vectors */
Vector3 test = new Vector3(4, 5, 6);
Vector3 test2 = new Vector3(0, 1, 2);
Vector3 found = Array.Find(vertices, x => x == test);
if (found != Vector3.zero) {
    Debug.Log("OK");
} else {
    Debug.Log("Not found");
}
Vector3 found2 = Array.Find(vertices, x => x == test2);
if (found2!= Vector3.zero) {
    Debug.Log("OK");
} else {
    Debug.Log("Not found");
}

What annoys me is that it always returns something, even when the element is not found. When the element is not found, it returns Vector3.zero.
My question is: what if you want to have a Vector3.zero in the array (which is my case actually)? How do you deal with that?

Your problem is that Array.Find<T> is defined to return a default(T) when nothing is found. As T in this case is a struct, and structs are value types, default(T) can not be null, but the default for that struct, which is equal to Vector3.zero. So there is no way for you to distinguish between a successfully found Vector3.zero, and no match.
Array.IndexOf(array, value) will return the index of the first element that is equal to value, or -1 if none is found. That should work just fine for you. If the result is not -1, you can use that result to get the matching element from your array.

I should not say "thank you in the comments". So... Thumbs up!! :)
