In this question I need to use a method 'AddItem' (found in an other .cs called Inventory) to add each item in my 'StoreStartingItem' array to the store's inventory.
I've tried simply calling the method and running the array through it like this:
Inventory.AddItem(StoreStartingItems);
However, I keep getting an error 'Argument 1: cannot convert from 'Shop.Item[]' to 'Shop.Item'
.
I've tried changing my 'AddItem' method from using a class parameter to a class array parameter like this:
public bool AddItem(Item item)
{
if (mItems == null)
return true;
else
return false;
}
To this:
public bool AddItem(Item[] item)
{
if (mItems == null)
return true;
else
return false;
}
But then I'm getting an error 'An object reference is required for the non-static field, method, or property 'Inventory.AddItem(Item[])'
'.
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…