A C# gotcha: when a base record overrides ToString(), the derived record compiler-generates its own ToString() that ignores the base implementation, producing output like 'DerivedRecord { Key = Test }' instead of just 'Test'. The fix, introduced in C# 10, is to mark the base record's ToString() override as sealed, preventing the compiler from regenerating it in derived records.

2m read timeFrom steven-giesel.com
Post cover image

Sort: