using System;
using System.Linq;
public class Test
{
public static void Main()
{
var itemNames = new [] { "a", "b", "c" };
var items1 = itemNames.Select(x => new Item(x));
var surprise = items1.Contains(items1.First());
var items2 = itemNames.Select(x => new Item(x)).ToList();
var noSurprise = items2.Contains(items2.First());
Console.WriteLine(surprise);
Console.WriteLine(noSurprise);
}
}
class Item
{
public Item(string name)
{
Name = name;
}
public string Name
{
get; set;
}
public override string ToString()
{
return Name;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKCnB1YmxpYyBjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCXZhciBpdGVtTmFtZXMgPSBuZXcgW10geyAiYSIsICJiIiwgImMiIH07CiAgICB2YXIgaXRlbXMxID0gaXRlbU5hbWVzLlNlbGVjdCh4ID0+IG5ldyBJdGVtKHgpKTsKICAgIHZhciBzdXJwcmlzZSA9IGl0ZW1zMS5Db250YWlucyhpdGVtczEuRmlyc3QoKSk7CiAgICB2YXIgaXRlbXMyID0gaXRlbU5hbWVzLlNlbGVjdCh4ID0+IG5ldyBJdGVtKHgpKS5Ub0xpc3QoKTsKICAgIHZhciBub1N1cnByaXNlID0gaXRlbXMyLkNvbnRhaW5zKGl0ZW1zMi5GaXJzdCgpKTsKICAgICAgICBDb25zb2xlLldyaXRlTGluZShzdXJwcmlzZSk7CiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUobm9TdXJwcmlzZSk7Cgl9Cn0KCmNsYXNzIEl0ZW0KewogICAgcHVibGljIEl0ZW0oc3RyaW5nIG5hbWUpCiAgICB7CiAgICAgICAgTmFtZSA9IG5hbWU7CiAgICB9CgogICAgcHVibGljIHN0cmluZyBOYW1lCiAgICB7CiAgICAgICAgZ2V0OyBzZXQ7CiAgICB9CgogICAgcHVibGljIG92ZXJyaWRlIHN0cmluZyBUb1N0cmluZygpCiAgICB7CiAgICAgICAgcmV0dXJuIE5hbWU7CiAgICB9Cn0=