C#C
C#4y ago
7 replies
Thinker

What is required for indexing with ranges? [Answered]

What exactly is required for indexing with a range (ex. obj[..3]) to be supported on a class? Just having an indexer public T this[int index] causes a type error because you can't convert between a range and an int. I've know Slice exists and supposedly has something to do with range indexing, but I can't get it to work by just having a public int Slice(int index, int length) method.
Was this page helpful?