From ca6bd1976bfb038a6d4d200484ae924dadfb1173 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Sat, 24 Jan 2026 11:08:26 -0500 Subject: [PATCH 1/2] support record with sealed ToString --- standard/classes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/standard/classes.md b/standard/classes.md index e2ee11ab2..88e5af33c 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -6245,7 +6245,9 @@ The record class shall include a synthesized method equivalent to a method decla public override string ToString(); ``` -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). +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). + +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`. The synthesized method: From 8befc0336a2f7557d6d50ae3a41092f2d15da031 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Tue, 10 Feb 2026 15:22:31 -0500 Subject: [PATCH 2/2] Clean up blank lines in classes.md Remove unnecessary blank lines from classes.md --- standard/classes.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/standard/classes.md b/standard/classes.md index 88e5af33c..f9bf7d066 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -6485,6 +6485,3 @@ A positional record class ([ยง15.2.1](classes.md#1521-general)) with at least on > ``` > > *end example* - - -