eavie
eavie

Reputation: 1

How to access arrays from multiple different forms?

Currently creating a project which requires me to declare a public array in the program class and then access and add to this array in one of my forms. When I declare the array in the program class, it says that it does not exist when I try to reference it in a different form.

How can I make the array accessible from all of my forms?

Upvotes: 0

Views: 155

Answers (1)

frankM_DN
frankM_DN

Reputation: 371

Declare it as a static variable in the Program class, something like:

public static string[] MyArr = {"my", "array"};

Then whenever you want to access it, use Program.MyArr.

Upvotes: 1

Related Questions