fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class User
  6. {
  7. public string Name { get; set; }
  8. }
  9.  
  10. public class Test
  11. {
  12. public static void Main()
  13. {
  14. var users = new List<User>
  15. {
  16. new User { Name = "John" },
  17. new User { Name = "Katia" },
  18. new User { Name = "Dmitry" },
  19. new User { Name = "James" },
  20. };
  21.  
  22. var names = new List<string> { "Dmitry", "Katia", "Vova" };
  23.  
  24. List<User> res = (from u in users join n in names on u.Name equals n select u).ToList();
  25.  
  26. foreach (var user in res)
  27. Console.WriteLine(user.Name);
  28. }
  29. }
Success #stdin #stdout 0.02s 15868KB
stdin
Standard input is empty
stdout
Katia
Dmitry