fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. List<int> ListMaster = new List<int>() { 1, 2, 3, 4 };
  10. List<int> List1 = new List<int>() { 1, 3, 4 };
  11. List<int> List2 = new List<int>() { 1, 3, 95 };
  12.  
  13. var inMaster1 = List1.Intersect(ListMaster);
  14. var inMaster2 = List2.Intersect(ListMaster);
  15.  
  16. foreach (var i in inMaster1)
  17. {
  18. Console.WriteLine(i);
  19. }
  20.  
  21. Console.WriteLine();
  22.  
  23. foreach (var i in inMaster2)
  24. {
  25. Console.WriteLine(i);
  26. }
  27. }
  28. }
Success #stdin #stdout 0.04s 34072KB
stdin
Standard input is empty
stdout
1
3
4

1
3