I was working on window appication previously where i used to create global variables using modules in vb.net, but i found that in C# there is no concept of modules. so how can i create global vaiables in C#
Well, you can use public static variables in public classes... but I'd really urge you not to.
Do these variables values change? What do they represent? Don't forget that all users will use the same set of variables.
Static members of static classes?
A quick Google search for C# tutorials produced this result:
http://www.csharp-station.com/tutorial.aspx
You should start at the beginning and try to learn the basics of OO programming.
Good luck.
If you are using ASP.NET, I would look at using Session and Application state, since ASP.NET is stateless. This is assuming you are talking about storing "Global" information across requests and not just having a container to hold values which multiple objects can access during one requests. If my assumption is wrong, I would look at Jon's answer.
http://msdn.microsoft.com/en-us/library/ms972429.aspx
Based on the comments below, you are going to want to take a look at creating a singleton pattern.
http://www.dofactory.com/patterns/PatternSingleton.aspx
Before doing this though, I would really take a look at why you want to use it in a ASP.NET application as it can seriously hurt performance if implemented incorrectly.
Since what you want to do surrounds db stuff I would also take a look at:
http://www.15seconds.com/Issue/040830.htm and http://msdn.microsoft.com/en-us/magazine/cc163854.aspx
A VB Module is basically a public static class in C#. But like Jon said, you really really have to come up with good reasons to use global variables.
You're talking about a web application, so I will recommend you to use Session State if your variables will be used in one session only. And I will recommend you to use Application State for application wide variables.
In ASP.Net, you can create the equivalent of global variables using the Cache object.
Cache["someName"] = "some value";
One benefit of using Cache is that you can put objects in it.
Another benefit is that you can alter the value in code.
You can also use the Application object, but Cache is preferred because of memory management.
As always, you should avoid overuse of these global variables, and minimize their size.
Globals? just say no. Globals should be avoided at all costs. If it's configuration data, use the application configuration stuff.
Or use either application, session or viewstate objects depending on your needs. But as "Jon Skeet" claims, using global variables should be avoided. But if you insist take a look at this link: Microsoft KB Article
you COULD use the global.aspx file, and have properties set in there. but as mentioned above... Why do you need a global variable? If you are trying to hold connection strings and system wide static vars.. put it in the web.config.
sorry mis read.. thats for Web apps.