I have two collections:
List<int> ids;
List<User> users;
Where User has id, name, etc.
I would like to inner join these two collections and return a new List<int> with ids from the first collection which are also in the second collection (User id’s).
I am new to LINQ and don’t know where to start.
Thanks.
You don’t need to use join to do this:
EDIT: In response to the question in the comments, you could get a list of users without using
Join:However this is quite inefficient since the
Whereclause has to scan the list of ids for each user. I think Join would be the best way to handle this case: