I would create a User class that has a property called LoggedIn. This propery would be an accessor to a bool type variable.
Code:
public class User
{
//Hidden field to hold if the user is logged in or not
protected bool mLoggedIn = false;
//Gets/Sets the logged in field
public bool LoggedIn
{
get
{
return mLoggedIn;
}
set
{
mLoggedIn = value;
}
}
}
You could then keep a list of users in either an ArrayList or a Hashtable if you need quick user lookups.
Personally, keeping a list of logged in users in memory of a single process doesn't really get you much unless you are writing a server that is accepting login requests. Obviously, I don't know what your requirements are or the purpose of the application so I may be completely off base. Usually, a client application doesn't need to know if more than one user is logged in because it only provides the interface for one user at a time.
If you need to make the data globally accessible to your application then you may want to investigate a design pattern called the "Singleton". It basically uses static members of a class to make data global across the process.
Does that make sense to you?
LT