probles using List.Find() method

J

Jeff

hi

asp.net 2.0

This code below don't work as it should be, I've now tested it in a scenario
where pictures contains a collection of 3 pictures:
#1, thumbnail = false
#2, thumbnail = true
#3, thumbnail = false

Picture picture = pictures.Find(delegate(Picture pic) { return
(pic.Thumbnail = true); });

The result is, (believe it or not) #1, thumbnail= true

I cannot believe it can get that value, looks like Find return the first
item in the collection and at the same time changes the Thumbnail property
on that object... I thought (pic.Thumbnail = true); was a search
parameter.... how wrong can I be... I was expecting item #2 as it has
thumbnail=true

any suggestions?
 
B

bruce barker

coding error on your part. you are setting (not comparing) the value to
true, then returning the new value;

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top