You can make an implementation of PersonList IEnumerable<Person>
public class PersonList : IEnumerable<Person> { public List<Person> myIntenalList; public IEnumerator<Person> GetEnumerator() { return this.myInternalList.GetEnumerator(); } Person CustomFunction() {...} }
Or even simpler, just add a PersonList to the List:
public class PersonList : List<Person> { Person CustomFunction() { ... } }
The first method has the advantage of not exposing List<T> methods, and the second is more convenient if you want this functionality. In addition, you must make myInternalList private.
source share