Current i am using this method to determine if a character is online:
public bool OnlineByServer(string username)
{
foreach (Character c in this.characters.Values)
{
if (c != null && c.Username.Equals(username))
{
return true;
}
}
return false;
}
Is there a faster way to do this?
There isn’t really a faster way of doing it, if you want to keep the characters as the dictionary Values. Due to being unsorted, a linear O(n) search has to be done.