HashSet<OrderDetailItem> list = new HashSet<OrderDetailItem>(); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938838", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938837", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338898", Barcode = "51023079339938836", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938835", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338898", Barcode = "51023079339938834", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938833", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938832", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938831", Num = 1 }); list.Add(new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938830", Num = 1 }); var item = new OrderDetailItem() { OrderNo = "23232322323", ProductCode = "338899", Barcode = "51023079339938837", Num = 1 }; var mbEntity = list.Where(d => d.Barcode == item.Barcode).FirstOrDefault(); bool b = list.Contains(item); //为什么b老是false