在我的案例Tag
中,如何从列表中删除Tag
值小于selectedPicture
值的列表中的每个元素(图片)。它不允许我使用<=
运算符说
运营商&#34;&lt; =&#34;不能应用于&#34;对象&#34;类型的操作数。和&#34;对象&#34;。
这是我做的:
pictureBoxList = pictureBoxList
.Where(picture => picture.Tag <= selectedPicture.Tag)
.ToList();
答案 0 :(得分:4)
正如错误所示,您无法使用<=
来比较对象。您需要根据基础类型的内容来转换Tag属性。例如,如果它是int
:
.Where(picture => (int)picture.Tag <= (int)selectedPicture.Tag)