From d8366ef3eb3b32150514ba2771212d90732c0685 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Sat, 24 Jan 2026 11:08:26 -0500 Subject: [PATCH] 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 b165e6cad..bfae8ce24 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -6341,7 +6341,9 @@ The record class shall include a provided method method declared as follows: 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 provided, 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, 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 the provided 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 providing a `ToString` method for any derived record types. However, this does not prevent the compiler from providing `PrintMembers`. The provided method: