Howdy, Stranger!

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


Where do I declare a global Var?

potyzpotyz Member Posts: 5
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?



  • ITAITA Member Posts: 463
    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.