现在的位置: 首页 > 综合 > 正文

how to pass a input parameter _HeaderToSearch in Predicate

2011年10月26日 ⁄ 综合 ⁄ 共 522字 ⁄ 字号 评论关闭

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. :)

抱歉!评论已关闭.