Where do I declare a global Var?

I have a class and I want to load just one instance of it (static) in the form. Then I want to access it with a button ...

Where do I have to declare the Var and with what syntax?

and how do I access it ...:
frmMain. ... what?



  • The variable should be declared outside of any methods in the class. This will make the variable global. To make the variable static simply add the 'static' keyword.

    class test
    static int test;

    The variable can then be accessed from the button's event handler.

    hope this helps.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion