Results 1 to 6 of 6

Thread: [RESOLVED] Mapping non-generic interfaces to generic collections

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Location
    cobwebbed to PC
    Posts
    311

    Resolved [RESOLVED] Mapping non-generic interfaces to generic collections

    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:
    1. 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
    Last edited by wolf99; Sep 22nd, 2017 at 08:07 AM.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width