Tech Off Post

Single Post Permalink

View Thread: How about some syntax sugar for IEnumerable<>?
  • User profile image
    stevo_

    Yes we all know this, but clearly what everyone is talking about here is having immutable interfaces as a step in the middle of IEnumerable and IWhateverMutableDataStructure...

    I'm still trying to understand why thats so hard to grasp.. nobody is wanting to corrupt what IEnumerable is.. we just want interfaces that describe the readonly actions of the common data structures that .NET has.. this is something I'm sure most people here have thought about even years ago.. I was thinking this time last year that I would love an immutable collection / dictionary interface.. and then wondering why they don't exist.. the great thing about the interface over the concrete type say.. ReadOnlyCollection.. is:

    - Allows complete variance on implementation
    - Allows you to expose the instance as either readonly or mutable in a cleaner way (vs keeping a reference to the underlying Collection that ReadOnlyCollection wraps)..