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
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5663,6 +5663,67 @@ An enumerable object provides an implementation of the `GetEnumerator` methods o
5663
5663
5664
5664
An asynchronous enumerable object provides an implementation of the `GetAsyncEnumerator` method of the `IAsyncEnumerable<T>` interface. This method returns an available asynchronous enumerator object. The enumerator object is initialized with the argument values and instance value saved when the enumerable object was initialized, including the optional cancellation token, but otherwise the enumerator object functions as described in [§15.15.5](classes.md#15155-enumerator-objects). An asynchronous iterator method can mark one parameter as the cancellation token using `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` ([§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute)). An implementation shall provide a mechanism to combine cancellation tokens such that an asynchronous iterator is canceled when either cancellation token (the argument to `GetAsyncEnumerator` or the argument attributed with the attribute `System.Runtime.CompilerServices.EnumeratorCancellationAttribute`) requests cancellation.
5665
5665
5666
+
## §rec-class Record classes
5667
+
5668
+
### §rec-class-general General
5669
+
5670
+
A record class is a specialized reference type that is optimized for storing data rather than behavior. It provides built-in functionality that would normally require significant “boilerplate” code in a non-record class, such as value-based equality and easy immutability.
A *record_class_declaration* consists of an optional set of *attributes* ([§21](attributes.md#21-attributes)), followed by an optional set of *class_modifier*s ([§14.2.2](classes.md#1422-class-modifiers)), followed by an optional `partial` modifier ([§14.2.7](classes.md#1427-partial-declarations)), followed by the keyword `record` and an *identifier* that names the class, followed by an optional *type_parameter_list* ([§14.2.3](classes.md#1423-type-parameters)), followed by an optional *delimited_parameter_list* ([§15.6.2.1](classes.md#15621-general)), followed by an optional *class_base* specification ([§14.2.4](classes.md#1424-class-base-specification)), followed by an optional set of *type_parameter_constraints_clause*s ([§14.2.5](classes.md#1425-type-parameter-constraints)), followed by a *record_class_body* (§rec-class-record-class-body).
5681
+
5682
+
*class_modifier* shall not be `static`.
5683
+
5684
+
A *record_class_declaration* having a *delimited_parameter_list* declares a ***positional record class***.
5685
+
5686
+
At most only one partial type declaration of a partial record class may provide a *delimited_parameter_list*.
5687
+
5688
+
Parameters in * delimited_parameter_list* shall not have `ref`, `out` or `this` modifiers; however, `in` and `params` modifiers are permitted.
5689
+
5690
+
### §rec-class-class-base-specification Class base specification
5691
+
5692
+
```ANTLR
5693
+
base_argument_list
5694
+
: '(' argument_list? ')'
5695
+
;
5696
+
```
5697
+
5698
+
### §rec-class-record-class-body Record class body
5699
+
5700
+
The *record_class_body* of a record class defines the members of that class.
5701
+
5702
+
```ANTLR
5703
+
record_class_body
5704
+
: class_body ';'?
5705
+
| ';'
5706
+
;
5707
+
```
5708
+
5709
+
The *record_class_body*s `{}`, `{};`, and `;` are equivalent. They all indicate that the only members are those synthesized by the compiler (§synth-members).
5710
+
5711
+
### §rec-class-class-members Class members
5712
+
5713
+
For a record class, the member set also includes the synthesized members generated by the compiler (§synth-members).
5714
+
5715
+
It is an error for a member of a record class to be named `Clone`.
5716
+
5717
+
It is an error for an instance field of a record class to have an unsafe type.
0 commit comments