adding Predicate usage to BusinessListBase and ReadOnlyListBase

adding Predicate usage to BusinessListBase and ReadOnlyListBase

Old forum URL: forums.lhotka.net/forums/t/1074.aspx


Tamir posted on Wednesday, August 30, 2006

hi, i just read about Predicate (http://developer.coreweb.com/articles/Default12.aspx)

i think it would be great if  BusinessListBase and ReadOnlyListBase will implement the same methods as System.Collections.Generic.List<T>  class implements.

for example:

public C Find(Predicate<C> match)
{
      if (match == null)
      {
            throw new ArgumentNullException("match");
      }
      for (int index = 0; index < base.Count; index++)
      {
            if (match(base[index]))
            {
                  return base[index];
            }
      }
      return default(C);
}
and this is a nice way of calling it.
PersonList persons = PersonList.GetAllPersons()}
Person me = persons.Find
                     (
                        delegate(Person p)
                        {
                           return p.Name == "Tamir"
                        }
                     ) 

RockfordLhotka replied on Wednesday, August 30, 2006

Yes, that seems like a nice idea for a future version.

Copyright (c) Marimer LLC