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?

thanx

Comments

  • 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.

    e.g:
    class test
    {
    static int test;
    }


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

    hope this helps.

    ITA
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!

Categories

In this Discussion