title: Current User Global Variable C# Desktop app
body: <p>I know that you can use session variables in web apps, I can't figure out how to use one in a desktop (windows forms and not a mobile android) one.</p>
  
  <p>I have a Player class that is used to associate players with other classes in the app/SQLDb (they may or may not be the active user).  But I want to have a CurrentPlayer (the person who actually has the application running) set.</p>
  
  <p>In the Program class at start up, I'm running checks to see if the current user exists and if not, add them to the SQLdb.  But at that time I'd like to set up an application-wide object for the user I've just added.  In fact, if they're not in the db they can't run the app.</p>
  
  <p>Obviously static doesn't work because I don't want to make the Player class static all the time.  But I really do need to have this object set and the info easily available.  EDIT:  The reason it can't be static all the time is that in every other instance but the current user, I definitely want the creation of a player object to take place.  I guess it's like the old Marine Corps thing.  There are many players but this one is mine. </p>
  
  <p>Yes, I know, global variables are not generally good, but here it makes sense (well I think so, if you all have other ideas I'm all ears), I just can't figure out how to implement it.</p>
  
  <p>EDIT:  I may not be being clear here.  I guess I kind of need a singleton maybe? but I don't know in which file to declare the instance or how.  </p>
  
  <p>I have a MYAPPPlayer class that is used generally for many many instances, it can/should not be static (unless I want to be a crappy dev).  But I need a MYAPPPlayer global singleton object variable for the current user of a non-web, desktop csharp app.</p>