2016-03-02 51 views
0

使用LINQ:我服務的對象列表其中包含的項目LINQ返回列表中找到

services[0] 
id=1, name="rental", ... 

services[1] 
id=2. name="buy", ... 

services[2] 
id=3. name="both", ... 

...等

我有[]數組包含了什麼樣的服務,從選擇的列表檢索[] = 1,3

foreach(var service in services.where(x=>x.id.Contains(selected)) 

這就是我卡住的地方我該如何在where子句中添加包含?

生成錯誤:包含運營商沒有找到

回答

0

試試你的陣列上使用Contains作爲反對id

foreach(var service in services.where(x => selected.Contains(x.id)) 
相關問題