Monday, June 12, 2006

How to declare global Variables in VB.NET and C#?

In VB.NET we have module to declare global variable, which can be accessed across all the forms

Module Module1
Public moduleinteger As Integer
End Module

In C#.NET we don't have any Module to declare global variables, so in C# we can declare a public class with public static variable which can be across all the forms

namespace Module{
public class Module1
public static int moduleinteger;

access like Module1.moduleinteger


At 10:45 PM, Blogger ajeet said...

This comment has been removed by the author.

At 3:20 AM, Blogger man said...

gr8 help

At 10:19 PM, Blogger NSY said...

finally know how to use global variable :P thank you

At 9:54 AM, Blogger Priya said...

Thanks a lot for this.
I do have one question though - what is the difference between 'const' and 'static'

Thanks in advance.

At 7:08 AM, Blogger vijay2040 said...

Thanks a lot...for ur valuable code...keep going on...

At 5:18 AM, Blogger Влад said...

thx you!


Post a Comment

<< Home