2012-04-26 70 views
-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; 
} 

我如何讓人們誰是在提供的房間不? : -/

+0

我試圖合併一些反函數,但我似乎無法得到它的工作。 – janhartmann 2012-04-26 19:19:17

+0

例如?代碼示例會有所幫助。 – Oded 2012-04-26 19:20:04

回答

7
var usersNotInRoom = _users.Values.Except(GetUsersInRoom("ROOM"));