In many of our projects, I saw several custom collections / container classes that contain some kind of common collection, for example. a List(of T).
Typically, they have a GetXXX method that returns an IEnumerable of any type that uses a custom collection class, so the internal collection can be iterated using a foreach loop.
eg.
public IEnumerable<UploadState> GetStates
{
get
{
return new List<UploadState>(m_states);
}
}
My question is whether these classes should instead implement an interface IEnumerableand call GetEnumeratorin the List itself.
Is there a preferred way, or does it depend on the developer?
bobbo source
share