Code inspection: Possible 'System.ArgumentOutOfRangeException'. Index must be a non-negative integer.
This inspection reports a constant negative index in index-from-end or range syntax. Negative index values are invalid and can cause runtime exceptions.
Example
var values = new[] { 10, 20, 30 };
var item = values[^-1];
The operand of ^ must not be negative.
How to fix it
There is no dedicated quick-fix for this inspection. Use a non-negative index instead.
var values = new[] { 10, 20, 30 };
var item = values[^1];
01 April 2026