I am trying to write a c# program that does following:
- Takes two parameters: a list of objects and a number
- Iterates through the list and find the first set of objects that equals to the number.
- Stop iteration if a set is found and the return the set.
So, I have a list of user defined object, say Person as an example. Say, Person object has two fields, Name and age. For example,
MyList
- Person1: John, 10
- Person2: Mary, 25
- Person3: Mike, 35
- Person4: Ann, 20
- Person5: Joe, 5
I want to find a set from the list that equals to the number that I am passing in. If I am passing in above list and 50, I want to return Person2, Person4, Person5 as a list.