Check if an array index is empty

I’m trying to find the first empty spot in my array, then add something there. The problem is this code:

if (inventory *== null)*

{
_ inventory = item;_
* print(“Added item”);*
* return;*
}
Without the check, it will add an item to the array, but only in the 1st spot of 6, no matter what’s there. Removing the return makes it use all 6 slots of course.
With the null check, it doesn’t meet the condition. I think it’s because of the class I’m using?
using UnityEngine;
using System.Collections;

public class Inventory : MonoBehaviour {

* public InventoryItem[] inventory;*

* [System.Serializable]*
* public class InventoryItem*
* {*
* public GameObject worldObject;*
* public Texture2D texRepresentation;*
* }*

* void Awake()*
* {*
* inventory = new InventoryItem[6];*
* }*

* public void AddItem(InventoryItem item)*
* {*
* for(int i = 0; i < inventory.Length; i++)*
* {*
_ if (inventory == null)
* {
inventory = item;
print(“Added item”);
return;
}
}
print(“Inventory full”);
}*_

* public void NewItem(GameObject worldObject, Texture2D texRep)*
* {*
* var newItem = new InventoryItem();*

* newItem.worldObject = worldObject;*
* newItem.texRepresentation = texRep;*

* AddItem(newItem); *
* }*
}

Solved it. It was much simpler than I thought!

if (inventory_.worldObject == null && inventory*.texRepresentation == null)*_

{
_ inventory = item;
* print(“Added item”);
return;
}*
Full script:
using UnityEngine;
using System.Collections;_

public class Inventory : MonoBehaviour {

* public InventoryItem[] inventory;*

* public bool displayInv = false;*

* [System.Serializable]*
* public class InventoryItem*
* {*
* public GameObject worldObject;*
* public Texture2D texRepresentation;*
* }*

* void Awake()*
* {*
* inventory = new InventoryItem[6];*
* }*

* void Update()*
* {*
* if (Input.GetButtonDown(“Inventory Key”))*
* {*
* if (!displayInv)*
* {*
* print(“Toggle Inv ON”);*
* displayInv = true;*
* }*
* else*
* {*
* print(“Toggle Inv OFF”);*
* displayInv = false;*
* }*
* }*
* }*

* public void AddItem(InventoryItem item)*
* {*
* for(int i = 0; i < inventory.Length; i++)*
* {*
if (inventory_.worldObject == null || inventory*.texRepresentation == null)
{
inventory = item;
print(“Added item”);
return;
}
}
print(“Inventory full”);
}*_

* public void NewItem(GameObject worldObject, Texture2D texRep)*
* {*
* var newItem = new InventoryItem();*

* newItem.worldObject = worldObject;*
* newItem.texRepresentation = texRep;*

* AddItem(newItem); *
* }*

* void OnGUI()*
* {*
* if (displayInv)*
* {*
* GUI.Box(new Rect(Screen.width / 2, Screen.height / 2,250,250), “test”);*
* }*
* }*

}