How to set value for property of an anonymous object?

Anonymous type properties are read only and they cannot be set.

Anonymous types provide a convenient way to encapsulate a set of
read-only properties
into a single object without having to explicitly
define a type first. The type name is generated by the compiler and is
not available at the source code level. The type of each property is
inferred by the compiler.

Anonymous Types (C# Programming Guide)

Leave a Comment