I have an array of objects (Character) of the Class Player which I instantiated in Form1
I need to use these objects in another form (Combat) but I’m not sure how to pass them though. Here is what I’ve tried:
public partial class Form1: Form
private void combatBtn_Click(object sender, EventArgs e)
{
Form combat = new Combat(Character[0-9]);
combat.ShowDialog();
}
public partial class Combat : Form
{
Player[] character = new Player[9];
public Combat(Player chars[0-9])
{
InitializeComponent();
for (int i = 0; i > 9; i++)
{
character[i] = chars[i];
}
}
You can add a property to
Combatand set it from the parent form:Then you can set that property when you create the form: