In C #, object initializers can set read-only public fields and properties.
However, with anonymous types, properties are read-only. So how does .NET set them to initialize an object?
An object initializer for anonymous types does not behave like a regular object initializer. those. it does not set properties directly. It translates into a constructor call that can change read-only fields.
Like all read-only properties, they can be set in the constructor.
, .
eg. just enter the fields with the corresponding binding flags, and then list and call SetValue with the correct parameters ...