Recently I used a class that inherits from a collection instead of having the collection instantiated within the class, is this acceptable or does it create unseen problems further down the road? Examples below for the sake of clarity:
public class Cars : List
instead of something like:
public class Cars
{
List CarList = new List();
}
Any thoughts?
Answer
The problem with this is that your Cars class will still have the interface it inherits from List, which may allow operations you don't want.
No comments:
Post a Comment