2 ms·
Inexing forwards sure. How many backwards then? And it mihjt be possible to add a static method to array to index backwards yourself (Can't remember what they
by _a_a_a_ 4y ago
Inexing forwards sure. How many backwards then?
And it mihjt be possible to add a static method to array to index backwards yourself (Can't remember what they are called, but look and act like methods on the object but aren't).
- int_19h 4y agoAll standard .NET collections with defined order and O(1) indexing support indexing backwards. And no, it's not possible to do this using an extension method, unfortunately - there are no extension properties or indexers in C# (yet; it's something that keeps coming up). But then again, if and when they add extension indexers, this arrangement with a custom type is what'd allow you to write one that does backwards indexing on a collection type that doesn't support it out of the box.