C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Where do I declare a global Var? Posted by potyz on 28 Oct 2003 at 11:19 AM
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
Report
Re: Where do I declare a global Var? Posted by ITA on 9 Dec 2003 at 12:25 PM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.