Question: I'm trying to make a program in Visual C# that has my one created class, and at application launch it creates an array of my class object, and this array of my object can be used all over the program. So any function, or a control's event can access the array of objects and their member variables.
I created my class as "public" but for some reason i get these errors upon build:
"The name 'MyArrayObjectNameHere' does not exist in the current context"
When I try to access the objects member variables inside a load file dialog event in which I am trying to load data from a file into the member variables of the object array.

Is there a certain place the object array needs to be declared and constructed so it exists in every context? If so, can you tell me where this is?

I currently declare it in the main function before form1 is run.

My class definition looks like this in its own .cs file and the programs namespace:

```
public class MyClass
{
    public int MyInt1;
    public int MyInt2;
}

```

I declare the array of objects like this inside the main function before the form load:

```
MyClass[] MyArrayObject;
MyArrayObject = new MyClass[50];
for (int i = 0; i < 50; i++)
{
    MyArrayObject[i] = new MyClass();
}

```

Thanks in advance for any help.

Answer: 
Your problem is that you are defining it within the main function, hence it will only exist inside the main function. you need to define it inside the class, not inside the function

```

public partial class Form1:Form
{
MyClass[] MyArrayObject; // declare it here and it will be available everywhere

public Form1()
{
 //instantiate it here
 MyArrayObject = new MyClass[50];
 for (int i = 0; i 
```
That't good.It is very useful for learners like me.