简体   繁体   English

从列表中删除基于对象属性的范围

[英]Remove from list a range based on an objects properties

I am trying to remove all integers from a list that are greater than 1 but also lower than 10, I end up removing every number below 10 including the required number 1. How could both conditions be satisfied using linq? 我试图从列表中删除大于1但小于10的所有整数,我最终删除10以下的每个数字,包括所需的数字1.如何使用linq满足两个条件? The code I currently have: 我目前的代码:

availableCards.RemoveAll(x => x.NumericalValue < 10 && x.NumericalValue > 1);

Use the linq statement 使用linq语句

var tempList= from card in availableCards
                where card.NumericalValue <=1 || card.NumericalValue >=10
                    select card;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM