title: C# : So if a static class is bad practice for storing global state info, what's a good alternative that offers the same convenience?
body: <p>I've been noticing static classes getting a lot of bad rep on SO in regards to being used to store global information. (And global variables being scorned upon in general) I'd just like to know what a good alternative is for my example below...</p>
  
  <p>I'm developing a WPF app, and many views of the data retrieved from my db are filtered based on the ID of the current logged in user. Similarly, certain points in my app should only be accessable to users who are deemed as 'admins'.</p>
  
  <p>I'm currently storing a <strong>loggedInUserId</strong> and an <strong>isAdmin</strong> bool in a static class.</p>
  
  <p>Various parts of my app need this info and I'm wondering why it's not ideal in this case, and what the alternatives are. It seems very convienient to get up and running.</p>
  
  <p>The only thing I can think of as an alternative is to use an IoC Container to inject a Singleton instance into classes which need this global information, the classes could then talk to this through its interface. However, is this overkill / leading me into analysis paralysis?</p>
  
  <p>Thanks in advance for any insight.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>So I'm leaning towards dependency injection via IoC as It would lend itself better to testability, as I could swap in a service that provides "global" info with a mock if needed. I suppose what remains is whether or not the injected object should be a singleton or static. :-)</p>
  
  <p>Will prob pick Mark's answer although waiting to see if there's any more discussion. I don't think there's a right way as such. I'm just interested to see some discussion which would enlighten me as there seems to be a lot of "this is bad" "that is bad" statements on some similar questions without any constructive alternatives.</p>
  
  <hr>
  
  <p><strong>Update #2</strong>
  So I picked Robert's answer seeing as it is a great alternative (I suppose alternative is a weird word, probably the One True Way seeing as it is built into the framework). It's not forcing me to create a static class/singleton (although it is thread static).</p>
  
  <p>The only thing that still makes me curious is how this would have been tackled if the "global" data I had to store had nothing to do with User Authentication.</p>