Code inspection: Replace 'Slice' with range indexer
This inspection reports calls to Slice(...) that can be written more clearly with the C# range indexer syntax. It typically appears when the start and end of the slice can be expressed directly as a range, including from-start and from-end forms such as [..5], [1..], or [^5..].
Example
Span<int> values = stackalloc[] { 1, 2, 3, 4, 5 };
var firstPart = values.Slice(0, 3);
var tail = values.Slice(2);
Span<int> values = stackalloc[] { 1, 2, 3, 4, 5 };
var firstPart = values[..3];
var tail = values[2..];
Quick-fix
Range indexers are shorter and make the slice boundaries easier to read at a glance.
30 March 2026