probles using List.Find() method

  • Thread starter Thread starter Jeff
  • Start date Start date
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?
 
coding error on your part. you are setting (not comparing) the value to
true, then returning the new value;

-- bruce (sqlwork.com)
 
Back
Top