set value of a property of an anonymous type using reflection / TypeDescriptor is it possible?

后端 未结 1 1056
Happy的楠姐
Happy的楠姐 2021-01-21 04:10

I tried using TypeDescriptor and the value is not changing, and via reflection I get an error that there is no setter for that property

1条回答
  •  旧时难觅i
    2021-01-21 04:58

    C# anonymous types are immutable, and their properties cannot be changed.

    If you really want to, you could set the backing field using reflection, but it would be a bad idea.

    0 讨论(0)
提交回复
热议问题