You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5136,14 +5137,15 @@ A type having an instance indexer taking a single argument of type `System.Index
5136
5137
> }
5137
5138
> }
5138
5139
> ```
5140
+
>
5139
5141
>*endexample*
5140
5142
5141
5143
#### §indexable-sequence-impl-support-for-index Implicit Index support
5142
5144
5143
5145
Animplementationshallbehaveasifitprovidesaninstanceindexermemberwithasingleparameteroftype `System.Index` for any type that meets the following criteria:
5144
-
- The type is countable [§14.7.1](classes.md#1471-general).
@@ -5158,6 +5160,7 @@ The provided instance indexer shall take the given `System.Index` and use that t
5158
5160
A type having an instance indexer taking a single argument of type `System.Range`, or a first argument of that type followed by optional arguments, may be indexed as described by [§11.7.10.3](expressions.md#117103-indexer-access).
@@ -5182,15 +5185,16 @@ A type having an instance indexer taking a single argument of type `System.Range
5182
5185
> }
5183
5186
> }
5184
5187
> ```
5188
+
>
5185
5189
>*endexample*
5186
5190
5187
5191
#### §indexable-sequence-impl-support-for-range Implicit Range support
5188
5192
5189
5193
Animplementationshallbehaveasifitprovidesaninstanceindexermemberwithasingleparameteroftype `System.Range` for any type that meets the following criteria:
5190
-
- The type is countable [§14.7.1](classes.md#1471-general).
> *Note*:Asspecifiedin [§11.7.10.2](expressions.md#117102-array-access), for array access, the method `System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray` is used instead of `Slice`. *end note*
5193
-
- The type does not have an accessible instance indexer taking a `System.Range` as its only argument, or as its first argument with the remaining arguments being optional.
5197
+
- The type does not have an accessible instance indexer taking a `System.Range` as its only argument, or as its first argument with the remaining arguments being optional.
5194
5198
5195
5199
The provided instance indexer shall have the same accessibility and return type, including `ref` if present, as `Slice`.
5196
5200
@@ -5199,6 +5203,7 @@ When the type is indexed with a `System.Range`, the provided instance indexer sh
>*Note*:See §indexable-sequence-expl-support-for-range for an example of an explicitly provided `Range` indexer. If that were not defined, its equivalent would be provided by the implementation, except that the provided indexer would call `Slice` to create and copy the slice. For type `BitArray`, `Slice` might be defined, as follows:
5206
+
>
5202
5207
> ```csharp
5203
5208
> public BitArray Slice(intstartIdx, intrangeLength)
5204
5209
> {
@@ -5211,6 +5216,7 @@ When the type is indexed with a `System.Range`, the provided instance indexer sh
5211
5216
>returnnewBitArray;
5212
5217
> }
5213
5218
> ```
5219
+
>
5214
5220
*endnote*
5215
5221
5216
5222
>NotetoTG2reviewers:Setter:Whatifanythingshouldwesayaboutimplicitandexplicitsetterfor a Range indexer? Certainly, one can define a setter for a user-defined type; however, itisnotobviousastowhatsuchasetterwoulddo, especiallysinceitmustbeusedontheleft-handsideofassignmenttakingaright-handsideofthesametypeastheindexreturns. Inthecaseoftype `BitArray` thatwouldmeansomethinglike `ba1[range1] =ba2`, orperhaps `ba1[range1] =ba2[range2]`. AsfarasRexcoulddetermine, theoperationsonemightliketoimplementusingsuchasetterareprobablybestimplementedviaanamedmethod. Inanyevent, foracompiler-generatedRangeindexer, attemptingtouseitssetterresultsintheerrormessage “CS0131Theleft-handsideofanassignmentmustbeavariable, propertyorindexer,” whichsuggeststhegeneratedindexer **hasnosetter**. Ifthatisthecase, weshouldsaythatintheprevioussection.
0 commit comments