How does ToString on an anonymous type work?

With anonymous objects…

The compiler generates an internal sealed class that models the
anonymous type. The anonymous type is immutable; all the properties
are read only. That class contains overrides of Equals() and
GetHashCode() that implement value semantics. In addition, the
compiler generates an override of ToString() that displays the value
of each of the public properties.

Source : link

Please, check @Ilya Ivanov answer to see some code about this subject.

Leave a Comment