Global variables

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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?
 

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