I am working on a multi-form program in C#, and would like to have arrays created whenever the program is run, as follows
private void Form1_Load(object sender, EventArgs e)
{
GlobalVariables();
MessageBox.Show("Number Of Users Check",
"There are " & Form1.AllAdmins.Length & " Admins" &
"There are " & Form1.AllLecturers.Length & " Lecturers" &
"There are " & Form1.AllStudents.Length & " Students");
}
public void GlobalVariables()
{
UserAdmin[] AllAdmins = new UserAdmin[0];
UserLecturer[] AllLecturers = new UserLecturer[0];
UserStudent[] AllStudents = new UserStudent[0];
}
According to Visual Studio my arrays do not exist.
How can I create these arrays in a way that would allow me to add data to them later, on a different form?
All of the above has changed, as i now understand that it would not work how i was hoping it would work. I now understand that global variables are a bad idea, and have moved over to having a list of items that is created on form load, as it allows us to add items to the list later.