c# List.Contains() Method Returns False

后端 未结 9 1883
梦毁少年i
梦毁少年i 2021-01-28 06:04

In the code block below I would expect dictCars to contain: { Chevy:Camaro, Dodge:Charger }

But, dictCars comes back empty. Because this line returns false each time it

9条回答
  •  暖寄归人
    2021-01-28 06:43

    myCars.Contains(newCar)
    myCars.Where(c =>  c.CarID == newCar.CarID && c.CarName==newCar.CarName).Count() > 0
    

提交回复
热议问题