Can't Assign Item In Array

So I’ve been working on an inventory script, I’m trying to test it out. Everything works fine except for the AddItem method, shown below.

    public void AddItem(Item item) {

            // Check if a stack is already there for us to stack the item with
		for(int i = 0; i <= 25; i++) {

                    // If nothing is in this inventory slot, check the next one.
			if(Items *== null) {*
  •  		continue;*
    
  •  	}*
    

// If stack is found, increase the stack size.
_ if(Items*.ContainingItem.Name == item.Name) {_
_ Items.StackSize++;
return;
}*_

* }*
// Create a new item stack.
* ItemStack st = new ItemStack(item, 1);*
// If no stacks of the same item is found, then
// check for space in inventory to put a new item stack into.
* for(int i = 0; i <= 25; i++) {*
// If item in inventory slot is null (no itemstack inside)
_ if(Items == null) {
// Add a new item stack.
Items = st;
* return;
}
}*_

_ /foreach(ItemStack i in Items) {
Debug.Log(i.ContainingItem.Name);
}/

* }*
Here’s my problem: whenever I add an item, it adds nothing, and the Debug.Log stuff doesn’t print anything, suggesting that nothing is being added to the array. Oddly enough, if I remove the 2 return statements the entire inventory is litterally filled with nothing but that item. Will somebody please fix this, or atleast explain why this is happening?
**EDIT: ** I’ve only included the AddItem method, I assure you everything else is working as expected.
**EDIT: **
Items is a built-in array, I thought to use this because it would work very well with the inventory slots stuff. ItemStack is a class with 3 properties: ContainingItem, StackSize, and MaxStackSize. Stacksize is just a public variable (I know, it’s bad, I’m sorry :P)
When an item that doesn’t exist in inventory is added into a non-full inventory it should just add that item.
When an item that does exist in inventory is added it should increase stack size, I haven’t checked if that works yet.
When the inventory is full, the item is dismissed and never seen from again. If you want the entire script here it is, but it’s a bit huge and messy, I’ll try to comment as much as I can.
*Pastebin link to my inventory script is here: http://pastebin.com/kxupp6Ap*_

*Item here: http://pastebin.com/YwB6ru29*_
*and ItemStack here: http://pastebin.com/4YRSc5Bz*_

Some more background would help:

  • Is Items a built-in array or a container class like List?
  • Is ItemStack a class or a struct?
  • Is StackSize an int-field or an int-property (or maybe something else?)

What things you have already tried to debug your problem? Where have you put Debug.Logs, what did you log and what was the result?

In general there are 3 different cases when you add an item:

  • You add a new item that doesn’t yet exists in the inventory. The inventory is not full.
  • You add an item that does already exist in the inventory
  • You try add an item that doesn’t yet exists, but the inventory is full.

With which case you have problems and what’s the exact result when you add the item? How far does the method run? Debug.Log?

With the information given it’s near to impossible to figure out what might be wrong. The given code looks solid except that the full inv situation isn’t handled at all and the item would just vanish.