The following code compiles:
var ints = Enumerable.Range(0, 10).ToArray();
var subset = ints[2..^2];
But this code doesn't:
var ints = Enumerable.Range(0, 10).ToList();
var subset = ints[2..^2];
The error message is, as you can see from the picture above, cannot convert from 'System.Range' to 'int'
.
Why is it that the C# 8 range operator only seems to work with arrays and not with lists? How do I use it with a list?