The Way to Programming
The Way to Programming
Simply inherits from List
Just look at the official documentation for List. The documentation often tells you more than what you read here and there, and you can usually count on it to be right. The Internet is full of false statements about everything.
Look at the Syntax portion of the documentation page, and you will see that List implements IEnumerable
If you still do not believe me, simply try a foreach on your class. Even without data in it, you will see that the syntax does not generate an error. It would give you an error just as your initial class if it did not implement GetEnumerator.
But change something in your last code. Because you inherits from List, your class is a List. You do not need to an internal list, you do not need to add anything:
public class DataExtractTablesColl : List{ }
You would add something if you wanted special constructors, supplementary methods and properties, or change the way some of the properties and methods work. Otherwise, inheriting from a class usually automatically gives you all its features. That is the first aim of inheritance.
Sign in to your account