I am working with a link list. The list has items based on inserted values from textboxes (size, height, stock, price). . Through the button click the Add function takes values from texboxes and appends item but every time I add an item to the list instead of placing at the end of the list it always placed first. I am not sure why such behavior. How can I modify so it can append the item always to the end of the list? (I am displaying my test results on a fifth multiline textbox called results).
Code
public void Add()
{
textBoxResults.Clear();
int stock = Convert.ToInt32(Stock.Text);
string type = Type.Text;
double price = Convert.ToDouble(Price.Text);
int height = Convert.ToInt32(Height.Text);
Tree = new FruitTrees();
Tree.Stock = stock;
Tree.Type = type;
Tree.Price = price;
Tree.Height = height;
Total += Tree.Price * Tree.Stock;
Trees.AddLast(Tree);
}
You could implement your own AddLast, something like this: