Reputation: 999
How can I remove each element(picture) from the list that has a Tag
value smaller than a Tag
value from some another picture, in my case selectedPicture
. It doesn't allow me to use <=
operator saying
Operator "<=" cannot be applied to operands of type "object" and "object".
Here is what I did:
pictureBoxList = pictureBoxList
.Where(picture => picture.Tag <= selectedPicture.Tag)
.ToList();
Upvotes: 1
Views: 217
Reputation: 101681
As the error suggests you can't use <=
to compare objects. You need to cast Tag property depending on what's the underlying type. For example if it's int
:
.Where(picture => (int)picture.Tag <= (int)selectedPicture.Tag)
Upvotes: 4