global variables

J

Jake

Do WinForms have "global variables"?

I know I could create an object in the presentation layer
with static variables to achieve the same effect, or use
app.config, but a co-worker asked me, and I didn't know
the answer.

Thanks,
Jake
 
H

Herfried K. Wagner [MVP]

* "Jake said:
Do WinForms have "global variables"?

I know I could create an object in the presentation layer
with static variables to achieve the same effect, or use
app.config, but a co-worker asked me, and I didn't know
the answer.

I don't think that this is related to Windows Forms. Windows Forms do
not have "global variables", but you can define, for example,
application "global" variables in .NET (public static members, or, in
VB.NET, public members of a module).
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Jake,

I believe the correct question would be "Does .NET platform support global
variables?"
The answer is: Yes, it does.
However, having global methods and variables is not CLS cmpliant and .NET
languages doesn't have to provide that feature.
For example:
C++ allows you to decalre clobal methods and variables, but C# doesn't
support this feature. Thus, if you wirte a library using C++ and decalre
golabal method that method cannot be used from C#.

More about CLS compliancy you can find in MSDN
ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconwhatiscommonlanguagespec
ification.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top