I'm kinda new to coding C# and I was trying to find a way to easely access values like:
item[currentItem].sellOrder[0].Position
But since I've never worked much with classes and C# I'm a bit lost and have no idea why this isn't working or what I'm doing wrong. Can someone give me a bit of help?
public class Item {
public int Pos {get;set;}
public string Name {get;set;}
public int Placement {get;set;}
public int socount = 0;
public class sellOrder {
public int Position {get;set;}
public int Quantity {get;set;}
public float Price {get;set;}
public sellOrder(int p, int q, float v) { Position = p; Quantity = q; Price = v; }
}
sellOrder[] sellOrderList;
public Item(int p, string n) { Pos = p; Name = n; Placement = -1; }
public void addSellOrder(int p, int q, float v) {
sellOrderList[socount] = new sellOrder(p, q, v);
socount++;
}
}
Sample:
Item[] item;
item = new Item[1];
item[0] = new Item(0, "testitem");
item[0].addSellOrder(1, 2, 10.2);
but when I try to access item[currentItem].sellOrder[0].Position I get:
error CS0119: 'Item.sellOrder' is a type, which is not valid in the given context
Thank you in advance, Regards
sellOrderis a class. You'd probably wantitem[currentItem].sellOrderList[0].Position