I have a base class called StockItem and one called EcoStockItem and a Plate subclass. EcoStockItem has a Juice object that is a subclass to EcoStockItem. In another class, I have the method AddItem (StockItem p). From the Form1 class should I send the StockItem item as a parameter to the method AddItem? I could not access the other property from subclasses. How should I do it? Create an object of StockItem to inherit all properties from subclasses and add it to a StockItem array?
StockItem
EcoStockItem
Plate
Juice
AddItem (StockItem p)
Form1
AddItem
newStockItem = new StockItem();
newStockItem.Id = id;
newStockItem.Name = name;
newStockItem.StockCount = stockcount;
newEcoStockItem =new EcoStockItem ();
newEcoStockItem.Markning = markning;
newPlate = new Plate();
newPlate.Typ = typ;
newJuice = new Juice();
newJuice.Typ = jtyp;
// StockItem p = ????
Stock stock = new Stock();
stock.AddItem(p);
and method:
public StockItem[] StockItems = new StockItem[10];
public void AddItem(StockItem item)
{
int index = GetCount();
StockItems[index] = item;
Form1.myForm.textBoxTest.Text = StockItems[index].ToString();
}