Say I want a list of values with a name and I already have
interface INamedItem
{
string Name { get }
}
Would I implement it like this:
class NamedValueList : List<ValueType>, INamedItem
{
public string INamedItem.Name { get; set }
...
}
or would I rather have it implement IList?
class NamedValueList : IList<ValueType>, INamedItem
{
public string INamedItem.Name { get; set }
private List<ValueType> _list = new List<ValueType>();
public Add(ValueType value)
{
_list.Add(value);
}
...
}
One way I'm open for any IList implementation, the other way I have to relay every IList call to my List object which seems not very efficient if I just want the list to have a name.
Or would I even implement IList myself instead of relaying the calls to my List object?
Is this pure preference or are there any good reasons to pick one of the solutions over the other?