how to pass a input parameter _HeaderToSearch in Predicate

Then, how to pass a input parameter _HeaderToSearch in Predicate?

1. To do that, we need to a new object called ListMatcher -

public class ListMatcher
{
private string _HeaderToSearch;
public ListMatcher(string headerToSearch)
{
_HeaderToSearch = headerToSearch;
}
public bool Predicate(SprintBacklogItem item)
{
return item.Title.StartsWith(_HeaderToSearch, StringComparison.InvariantCultureIgnoreCase);
}
}  

2. Next , I initialized the ListMatcher object and use the HeaderToSearch  to filter the items- 

ListMatcher matcher = new ListMatcher("QA");
this.FindAll(matcher.Predicate);

Done. :)

posted on 2008-07-13 23:10  mikelij  阅读(164)  评论(0编辑  收藏  举报

导航