In this SO question, https://stackoverflow.com/a/46363899/1292918, Hans Passant mentions:
"Mapping your own non-generic interface to a generic collection type"
What is meant by this exactly? How does one go about it?
My initial though was that it meant replacing generic interface usage with non-generic ones, eg, replacing IList<T> usage with IEnumerable or ArrayList usage.
But then I thought maybe it means creating my own IStringList type to replace IList<T> with instead of either of the aforementioned types... that would mean the following, right?
c# Code:
public interface IStringList : IList<string> { /* empty */ }
Update:Asked Hans about this latter code in a comment, he said "No, encapsulation is the appropriate choice". Unsure what is meant by this but SO is not the format to dig into details really




Reply With Quote