I'm involved in a personal project where I want to work out a calculator with some items that are inserted in arrays. I chose a class called "calc.cs" to construct a method with a code similar to this
public void AddDrinkstoTabbedpanel()
{
List<string> drinks = new List<string>();//New list empty
food foo = new food();//Call food to get drinks
string [] product = foo.name;//string product [] = food.name (drinks)
foreach (string value in product)//(string value in product)//for any "value" in product
{
drinks.Add(value);//Add these value to list
Button bt = new Button();//new button(s)
bt.Text = value.ToString();//Add text to button
}
}
I tried to get the "items" that are stored in "arrays" by entering: Messagebox.Show(value);
and in fact I get all the items I want.
However, the solution does not create the button for each item, why?
Where I failed, what's wrong?