-1

我有这个代码:

private static readonly Dictionary<string, ChatUser> _users = new Dictionary<string, ChatUser>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, ChatRoom> _rooms = new Dictionary<string, ChatRoom>(StringComparer.OrdinalIgnoreCase);

public IEnumerable<ChatUser> GetUsersInRoom(string room)
{
    if (String.IsNullOrEmpty(room))
    {
        return Enumerable.Empty<ChatUser>();
    }

    var results = from name in _rooms[room].Users
                           select _users[name];

    return results;
}

我如何找到不在提供房间的人?:-/

4

1 回答 1

7
var usersNotInRoom = _users.Values.Except(GetUsersInRoom("ROOM"));
于 2012-04-26T19:20:24.643 回答