Wow. I seem to be having a lot of questions. Hmm. Well, it's been a great learning experience. But...
public void InvetoryTest()
{
HP = 5;
HealingItem heal = new HealingItem();
HarmfulItem harm = new HarmfulItem();
Item[] inventory = { heal, harm };
int itemValue;
object itemType = harm;
itemValue = Array.BinarySearch(inventory, itemType);
Console.WriteLine(HP);
Item itemName = (Item)inventory.GetValue(itemValue);
itemName.ApplyItem();
Console.WriteLine(HP);
Console.ReadLine();
}
So running that code (with other relevant methods), I get the following error:
Failed to compare two elements in the array.
{/quote]
If I change itemType to heal, then there's no error. If I switch the position of harm and heal, putting harm at 0 and heal at 1 and leave itemType as harm, it works. But if, after switching them, I make itemType heal, it breaks again. Basically, if itemType is the item at 0, I get that error.
If I try to put NULL in the array, either at the beginning or end of it, then things are reversed. If itemType is the item at 1, it breaks. It's really quite boggling.
What am I missing?
[edit]
If I don't have the variables declared in that block, it's because they're declared elsewhere, outside the method.
[/edit]