Skip to content

Commit a37698d

Browse files
authored
support record with sealed ToString
1 parent 20f8f91 commit a37698d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

standard/classes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6245,7 +6245,9 @@ The record class shall include a synthesized method equivalent to a method decla
62456245
public override string ToString();
62466246
```
62476247

6248-
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility, or if the explicit declaration doesn't allow overriding it in a derived type and the record class type is not sealed. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
6248+
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
6249+
6250+
Sealing an explicitly declared `ToString` method prevents the compiler from synthesizing a `ToString` method for any derived record types. However, this does not prevent the compiler from synthesizing `PrintMembers`.
62496251

62506252
The synthesized method:
62516253

0 commit comments

Comments
 (0)