Scope of Variables in Windows Forms
Posted on 2004-11-08
Could someone tell me if there is an exception to variable scope with Windows forms? The way I understand it, is that a form is just another class. So in theory, if a variable is defined as private in a windows form it should not be accessible to other objects in the code and vice versa correct? I'm asking this question because I am having the following problem which I am not understanding:
I am building an add-in for word. In the main class, Connect, I declare a private arraylist variable named "x". I also have a form which contains an arraylist variable declared as private which is also named "x". For some reason, if I add and object to the arraylist within the form code, it makes its way into the private arraylist defined in the calling class. Does anyone know why this would happen? I am showing the form as a dialog box if that makes a difference.
Thanks in advance for your help!