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
Copy file name to clipboardExpand all lines: standard/classes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3303,7 +3303,7 @@ ref_property_body
3303
3303
3304
3304
*unsafe_modifier* ([§23.2](unsafe-code.md#232-unsafe-contexts)) is only available in unsafe code ([§23](unsafe-code.md#23-unsafe-code)).
3305
3305
3306
-
A *property_declaration* may include a set of *attributes* ([§22](attributes.md#22-attributes)) and any one of the permitted kinds of declared accessibility ([§15.3.6](classes.md#1536-access-modifiers)), the `new` ([§15.3.5](classes.md#1535-the-new-modifier)), `static` ([§15.7.2](classes.md#1572-static-and-instance-properties)), `virtual` ([§15.6.4](classes.md#1564-virtual-methods), [§15.7.6](classes.md#1576-virtual-sealed-override-and-abstract-accessors)), `override` ([§15.6.5](classes.md#1565-override-methods), [§15.7.6](classes.md#1576-virtual-sealed-override-and-abstract-accessors)), `sealed` ([§15.6.6](classes.md#1566-sealed-methods)), `abstract` ([§15.6.7](classes.md#1567-abstract-methods), [§15.7.6](classes.md#1576-virtual-sealed-override-and-abstract-accessors)), `extern` ([§15.6.8](classes.md#1468-external-methods)), and `readonly` modifiers. However, it is a compile-time error for the *property_modifier* `readonly` to be used in a *property_declaration* that is not contained directly by a *struct_declaration* (([§15.4.11](structs.md#16411-properties)).
3306
+
A *property_declaration* may include a set of *attributes* ([§22](attributes.md#22-attributes)) and any one of the permitted kinds of declared accessibility ([§15.3.6](classes.md#1536-access-modifiers)), the `new` ([§15.3.5](classes.md#1535-the-new-modifier)), `static` ([§15.7.2](classes.md#1572-static-and-instance-properties)), `virtual` ([§15.6.4](classes.md#1564-virtual-methods), [§15.7.6](classes.md#1576-virtual-sealed-override-and-abstract-accessors)), `override` ([§15.6.5](classes.md#1565-override-methods), [§15.7.6](classes.md#1576-virtual-sealed-override-and-abstract-accessors)), `sealed` ([§15.6.6](classes.md#1566-sealed-methods)), `abstract` ([§15.6.7](classes.md#1567-abstract-methods), [§15.7.6](classes.md#1576-virtual-sealed-override-and-abstract-accessors)), `extern` ([§15.6.8](classes.md#1568-external-methods)), and `readonly` modifiers. However, it is a compile-time error for the *property_modifier* `readonly` to be used in a *property_declaration* that is not contained directly by a *struct_declaration* (([§16.4.11](structs.md#16411-automatically-implemented-properties)).
3307
3307
3308
3308
- The first declares a non-ref-valued property. Its value has type *type*. This kind of property may be readable and/or writeable.
3309
3309
- The second declares a ref-valued property. Its value is a *variable_reference* ([§9.5](variables.md#95-variable-references)), that may be `readonly`, to a variable of type *type*. This kind of property is only readable.
@@ -3395,7 +3395,7 @@ For a ref-valued property the *ref_get_accessor_declaration* consists optional a
3395
3395
The use of *accessor_modifier*s is governed by the following restrictions:
3396
3396
3397
3397
- An *accessor_modifier* shall not be used in an interface or in an explicit interface member implementation.
3398
-
- It is a compile-time error for the *accessor_modifier*`readonly` to be used in a *property_declaration* or *indexer_declaration* that is not contained directly by a *struct_declaration* (§cands-diffs-properties, §cands-diffs-indexers).
3398
+
- It is a compile-time error for the *accessor_modifier*`readonly` to be used in a *property_declaration* or *indexer_declaration* that is not contained directly by a *struct_declaration* (§16.4.11, §cands-diffs-indexers).
3399
3399
- For a property or indexer that has no `override` modifier, an *accessor_modifier* is permitted only if the property or indexer has both a get and set accessor, and then is permitted only on one of those accessors.
3400
3400
- For a property or indexer that includes an `override` modifier, an accessor shall match the *accessor_modifier*, if any, of the accessor being overridden.
3401
3401
- The *accessor_modifier* shall declare an accessibility that is strictly more restrictive than the declared accessibility of the property or indexer itself. To be precise:
> *Note*: Thisaccessrestrictionmeansthatconstructorsinstructscontainingautomaticallyimplementedpropertiesoftenneedanexplicitconstructorinitializer where they would not otherwise need one, to satisfy the requirement of all fields being definitely assigned before any function member is invoked or the constructor returns. *end note*
507
507
508
-
A *property_declaration* ([§14.7.1](classes.md#1471-general)) for an instance property in a *struct_declaration* may contain the *property_modifier* `readonly`. However, a static property shall not contain that modifier.
508
+
A *property_declaration* ([§15.7.1](classes.md#1571-general)) for an instance property in a *struct_declaration* may contain the *property_modifier* `readonly`. However, a static property shall not contain that modifier.
509
509
510
510
It is a compile-time error to attempt to modify the state of an instance struct variable via a readonly property declared in that struct.
511
511
@@ -523,7 +523,7 @@ If the `get` accessor has a `readonly` modifier, the `set` shall exist and shall
523
523
524
524
### §cands-diffs-methods Methods
525
525
526
-
A *method_declaration* ([§14.6.1](classes.md#1461-general)) for an instance method in a *struct_declaration* may contain the *method_modifier* `readonly`. However, a static method shall not contain that modifier.
526
+
A *method_declaration* ([§15.6.1](classes.md#1561-general)) for an instance method in a *struct_declaration* may contain the *method_modifier* `readonly`. However, a static method shall not contain that modifier.
527
527
528
528
It is a compile-time error to attempt to modify the state of an instance struct variable via a readonly method declared in that struct.
529
529
@@ -535,7 +535,7 @@ All *method_declaration*s of a partial method shall have a `readonly` modifier,
535
535
536
536
### §cands-diffs-indexers Indexers
537
537
538
-
An *indexer_declaration* ([§14.9](classes.md#149-indexers)) for an instance indexer in a *struct_declaration* may contain the *indexer_modifier* `readonly`.
538
+
An *indexer_declaration* ([§15.9](classes.md#159-indexers)) for an instance indexer in a *struct_declaration* may contain the *indexer_modifier* `readonly`.
539
539
540
540
It is a compile-time error to attempt to modify the state of an instance struct variable via a readonly indexer declared in that struct.
541
541
@@ -547,7 +547,7 @@ If the `get` accessor has a `readonly` modifier, the `set` shall exist and shall
547
547
548
548
### §cands-diffs-events Events
549
549
550
-
An *event_declaration* ([§14.8.1](classes.md#1481-general)) for an instance, non-field-like event in a *struct_declaration* may contain the *event_modifier* `readonly`. However, a static event shall not contain that modifier.
550
+
An *event_declaration* ([§15.8.1](classes.md#1581-general)) for an instance, non-field-like event in a *struct_declaration* may contain the *event_modifier* `readonly`. However, a static event shall not contain that modifier.
0 commit comments