c# - Treat a classes member as a type to use as a parameter in a search function -
this question has answer here:
i'm writing method searches list of person
's matches based on single member of person
class. i'd pass in person
list (to search), matchpair
list (for results), , specify member of person
class going use search criteria.
public void matchwithsinglemember(list<matchpair> pairlist, list<person> personlist, ______ searchattribute) { (int = 0; < personlist.count; ++i) { (int j = + 1; j < personlist.count; ++j) { if (personlist[i].searchmember == personlist[j].searchmember && personlist[i].searchmember != null) { matchpair matchpair = new matchpair(personlist[i], personlist[j]); pairlist.add(matchpair); } } } }
this way, if wanted produce list of matches based of person
class member: phone1, specify somehow parameter when calling above method.
matchwithsinglemember(results, listofpersons, __________);
is there way this? please let me know if i'm not being clear enough.
Comments
Post a Comment