code_junkie

intro to lambda/anonymous functions

Nov 13th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // This method implements the test condition for
  2. // finding the ResolutionInfo.
  3. private static bool IsResolutionInfo(ImageResource res)
  4. {
  5. return res.ID == (int)ResourceIDs.ResolutionInfo;
  6. }
  7.  
  8. get
  9. {
  10. return (ResolutionInfo)m_imageResources.Find(IsResolutionInfo);
  11. }
  12.  
  13. get
  14. {
  15. return (ResolutionInfo)m_imageResources.Find(res => res.ID == (int)ResourceIDs.ResolutionInfo);
  16. }
  17.  
  18. public T Find(Predicate<T> match)
  19. {
  20. if (match == null)
  21. {
  22. ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
  23. }
  24. for (int i = 0; i < this._size; i++)
  25. {
  26. if (match(this._items[i]))
  27. {
  28. return this._items[i];
  29. }
  30. }
  31. return default(T);
  32. }
Add Comment
Please, Sign In to add comment