Take the 2-minute tour ×  I have a list of about 10,000 staff
members in a List<T> and I have a ListBox which contains a
subset of those staff, depending on the search term in a text
box.  Say a Staff object has the following publicly exposed
properties:  string FirstName string LastName string MiddleName
int StaffID    int CostCentre  I could write a function like
this:  bool staffMatchesSearch(Staff stf)   if
(tbSrch.Text.Trim() == string.Empty)     return true; // No
search = match always.    string s =
tbSrch.Text.Trim().ToLower();    // Do the checks in the order
most likely to return soonest:   if
(stf.LastName.ToLower().Contains(s))     return true;   if
(stf.FirstName.ToLower().Contains(s))     return true;   if
(stf.MiddleName.ToLower().Contains(s))     return true;    if
(stf.CostCentre.ToString().Contains(s))     return true; // Yes,
we want partial matches on CostCentre   if
(stf.StaffID.ToString().Contains(s))     return true; // And
also on StaffID    return false;  and then do something like