About System.Range Extension Support #8267
-
I wrote an extension method for Range, but I encountered a problem that Index is non-negative Currently, only Range supports the range expression Start...End. There is no room for extensions for other classes with the same Range semantics. Extract an abstract interface for Range. The compiler-generated code for Range should be changed to use this interface. If possible, it could even be IRange range = new MyRange('a', 'c');
foreach(var item in range)
......
foreach(var item in a...c)
...... Of course, the std library only needs to generate a default Range when a specific implementation is not specified. Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Being non-negative for For such |
Beta Was this translation helpful? Give feedback.
Both
System.Range
and the range expression mean "range of linear collection". They don't mean other ranges.