How do I check if specific game object is in specific array?

Let’s say I have a game object that can be in two different arrays, say arr1 and arr2. Then after some event in a game I need to check which array it belongs to. I have used tag and layer for other stuff, so that’s out. I don’t know what name that object may have either, so reference to GameObject is all I have. How do I check which object array the GO belongs to?

If you don’t use it in update or you aren’t at the edge of performance you can simply switch to list and use contains(),

Otherwise use navot’s solution e.g. custom contains function.

Code example:

bool ArrayContains (GameObject[] array, GameObject g) {
    for(int i = 0; i < array.length; i++) {
        if (array *== g) return true;*

}
return false;
}