This project has moved. For the latest updates, please go here.

A couple of questions

Nov 6, 2014 at 8:23 AM

This is a neat library! I created something similar a while ago, but as a purely readonly view of the underlying collection (i.e. IReadOnlyList<T> from .NET 4.5). I found that approach good enough for parsing binary data, and it gets handy because you can implement IEnumerable-like extensions like Select or Concat which can also create lightweight wrappers, but are not possible if you allow mutating the elements.

One detail: Is there a reason you didn't allow wrapping a IList<T> instead of an array?

Nov 6, 2014 at 7:58 PM
I didn't actually write ArraySegment<T>; it's part of the BCL.

This library just adds a whole lot of helper extension methods to make things easier. It's nothing that couldn't be done by hand, but it's nice to fix all the off-by-one errors in one place. :)

ArraySegment does specifically reference an underlying array instead of an IList. This is primarily useful when used as input/output: at the p/Invoke layer, most methods just take arrays (or array+position+length, which is essentially an ArraySegment).

That said, there is certainly room for a library that provides IList-based "views". I've played around with this a couple times over the years but those experiments never got to production.