I created a list in my main Form that I wanted to pass to my other forms.
public class MainZoo : Form
{
public List <Animal> animal;
public MainZoo(List<Animal> animal)
{
InitializeComponent();
var newAnimal = animal;
}
That’s my main form, from where I will be open the rest of the forms. I thought I could pass the list using that variable to other forms, when I am opening them. It seems there is an issue in my thinking process, because I can’t "reach" that list from the main form (other forms are inherited from Form, not MainZoo). I was thinking about "get and set", but how? I just saw it, but I don’t know how I should pass that list using that thing.
private void LandAnimalButton_Click(object sender, EventArgs e)
{
Form Land = new LandAnimalFormcs();
Land.ShowDialog();
var newAnimal = animal;
}
This code is still in the main form.