c# - Finding matches that contain certain text in properties using LINQ -


i trying convert following code linq

foreach (var item in pagehistorycol)     {         if (item.pagetitle.contains(text) || item.pageuri.contains(text))         {             temphistory.insert(0, item);         }     } 

the following returns items instead of matches

var matches = pagehistorycol.where(item =>      (item.pagetitle.contains(text) || item.pageuri.contains(text))); 

what missing?

the 2 statements displayed should return same items. if second returns items, foreach loop should add of items temphistory well.

the main difference foreach loop return items in opposite order linq query. if order of matches important, can items in same order using:

var matches = pagehistorycol      .where(item => item.pagetitle.contains(text) || item.pageuri.contains(text))      .reverse(); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -