我有这段代码:
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;
}
如何在所提供的房间内找到不的人? : - /
答案 0 :(得分:7)
var usersNotInRoom = _users.Values.Except(GetUsersInRoom("ROOM"));