I have a class named Item which acts as an abstract class, but is not defined as one. This class has a MaxPerStack property:
public class Item
{
public short MaxPerStack
{
get
{
return this.Data.MaxPerStack;
}
}
}
I also have a class named Equip which derives from the Item class and also has a property named MaxPerStack which is declared as new:
public class Equip : Item
{
public new short MaxPerStack
{
get
{
return 1;
}
}
}
I have the following method called Add, which uses the MaxPerStack property of item:
public void Add(Item item)
{
Console.WriteLine("Stack: {0}.", item.MaxPerStack);
}
When I do:
Add(new Equip());
It goes to the MaxPerStack property of Item rather to the Equip one.
Why's that happening?