From 36b3b28d6077ac7165b7d84c7df657f4bb6027d2 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 3e89056da..d13b4041c 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -6282,7 +6282,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 e8f79d15b835615db83a404d729b4cfe4c829dcc 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 d13b4041c..b32db5665 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -6522,6 +6522,3 @@ A positional record class ([ยง15.2.1](classes.md#1521-general)) with at least on > ``` > > *end example* - - -