Global variables

  • Thread starter Thread starter PokerMan
  • Start date Start date
P

PokerMan

Hey guys

Can people give me their views on this.

When i make a cs class file for my asp.net app i cant use Application
objects for my globals?

But if i was to make a singleton class say and call it MyGlobals and load
all my global vars into it at the start and then access this, any of my
class files throughout my app can get to the vars.

So my questions are: a) why isnt the singleton class a good idea? and b) why
cant i access my application object from my app_code cs files?

thanks
 
PokerMan said:
Hey guys

Can people give me their views on this.

When i make a cs class file for my asp.net app i cant use Application
objects for my globals?

If it's only going to be using in an ASP.NET application, yes you can.
But if i was to make a singleton class say and call it MyGlobals and load
all my global vars into it at the start and then access this, any of my
class files throughout my app can get to the vars.

So my questions are: a) why isnt the singleton class a good idea?

If you are positive that you can implement a thread safe singleton
class, you can use it. However it seems like overkill, when a simple
static class will work just fine.
and b) why
cant i access my application object from my app_code cs files?

Because you don't know how to do it?
 
Back
Top