fork(6) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7.  
  8. public class Details
  9. {
  10. public int id;
  11. public string symbol;
  12. public string code;
  13. public override string ToString() {
  14. return string.Format("{0} {1} {2}", id, symbol, code);
  15. }
  16. }
  17.  
  18. public static void Main()
  19. {
  20. List<Details> list1 = new List<Details>();
  21. List<Details> list2 = new List<Details>();
  22.  
  23. list1.Add(new Details() { id=1,symbol="ANSI",code="NITE"});
  24. list1.Add(new Details() { id = 1, symbol = "ANSI", code = "CALGO" });
  25. list1.Add(new Details() { id = 1, symbol = "ANSI", code = "CANT" });
  26. list1.Add(new Details() { id=2,symbol="ANSI",code="NITE"});
  27. list1.Add(new Details() { id = 2, symbol = "ANSI", code = "CALGO" });
  28. list1.Add(new Details() { id = 2, symbol = "ANSI", code = "CANT" });
  29.  
  30. list2.Add(new Details() { id = 1, symbol = "ANSI", code = "NITE" });
  31. list2.Add(new Details() { id = 1, symbol = "ANSI", code = "CALGO" });
  32. list2.Add(new Details() { id = 2, symbol = "ANSI", code = "NITE" });
  33. foreach (var v in
  34. list1.Where(x=>
  35. list2.Any(z=>x.id==z.id && x.symbol==z.symbol)
  36. && !list2.Any(z => x.id==z.id && x.symbol==z.symbol && x.code==z.code))
  37.  
  38. ) {
  39. Console.WriteLine(v);
  40. }
  41. }
  42. }
Success #stdin #stdout 0s 29800KB
stdin
Standard input is empty
stdout
1 ANSI CANT
2 ANSI CALGO
2 ANSI CANT