Could/Should I use static classes in asp.net/c# for shared data?

Posted by death.au on Stack Overflow See other posts from Stack Overflow or by death.au
Published on 2010-05-07T01:27:51Z Indexed on 2010/05/07 1:38 UTC
Read the original article Hit count: 161

Filed under:
|
|
|

Here's the situation I have: I'm building an online system to be used by school groups. Only one school can log into the system at any one time, and from that school you'll get about 13 users. They then proceed into a educational application in which they have to co-operate to complete tasks, and from a code point of view, sharing variables all over the place.

I was thinking, if I set up a static class with static properties that hold the variables that are required to be shared, this could save me having to store/access the variables in/from a database, as long as the static variables are all properly initialized when the application starts and cleaned up at the end. Of course I would also have to put locks on the get and set methods to make the variables thread safe.

Something in the back of my mind is telling me this might be a terrible way of going about things, but I'm not sure exactly why, so if people could give me their thoughts for or against using a static class in this situation, I would be quite appreciative.

© Stack Overflow or respective owner

Related posts about c#

Related posts about static