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
@@ -5237,14 +5238,15 @@ A type having an instance indexer taking a single argument of type `System.Index
5237
5238
> }
5238
5239
> }
5239
5240
> ```
5241
+
>
5240
5242
>*endexample*
5241
5243
5242
5244
#### §indexable-sequence-impl-support-for-index Implicit Index support
5243
5245
5244
5246
Animplementationshallbehaveasifitprovidesaninstanceindexermemberwithasingleparameteroftype `System.Index` for any type that meets the following criteria:
5245
-
- The type is countable [§14.7.1](classes.md#1471-general).
@@ -5259,6 +5261,7 @@ The provided instance indexer shall take the given `System.Index` and use that t
5259
5261
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).
@@ -5283,15 +5286,16 @@ A type having an instance indexer taking a single argument of type `System.Range
5283
5286
> }
5284
5287
> }
5285
5288
> ```
5289
+
>
5286
5290
>*endexample*
5287
5291
5288
5292
#### §indexable-sequence-impl-support-for-range Implicit Range support
5289
5293
5290
5294
Animplementationshallbehaveasifitprovidesaninstanceindexermemberwithasingleparameteroftype `System.Range` for any type that meets the following criteria:
5291
-
- 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*
5294
-
- 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.
5298
+
- 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.
5295
5299
5296
5300
The provided instance indexer shall have the same accessibility and return type, including `ref` if present, as `Slice`.
5297
5301
@@ -5300,6 +5304,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:
5307
+
>
5303
5308
> ```csharp
5304
5309
> public BitArray Slice(intstartIdx, intrangeLength)
5305
5310
> {
@@ -5312,6 +5317,7 @@ When the type is indexed with a `System.Range`, the provided instance indexer sh
5312
5317
>returnnewBitArray;
5313
5318
> }
5314
5319
> ```
5320
+
>
5315
5321
*endnote*
5316
5322
5317
5323
>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