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.

你可能感兴趣的:(parameter)