fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var itemNames = new [] { "a", "b", "c" };
  9. var items1 = itemNames.Select(x => new Item(x));
  10. var surprise = items1.Contains(items1.First());
  11. var items2 = itemNames.Select(x => new Item(x)).ToList();
  12. var noSurprise = items2.Contains(items2.First());
  13. Console.WriteLine(surprise);
  14. Console.WriteLine(noSurprise);
  15. }
  16. }
  17.  
  18. class Item
  19. {
  20. public Item(string name)
  21. {
  22. Name = name;
  23. }
  24.  
  25. public string Name
  26. {
  27. get; set;
  28. }
  29.  
  30. public override string ToString()
  31. {
  32. return Name;
  33. }
  34. }
Success #stdin #stdout 0.01s 29800KB
stdin
Standard input is empty
stdout
False
True