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
Asked
Active
Viewed 2,489 times
3
-
2You'll get better answers if you post some code that illustrates the problem. – ChrisF May 04 '10 at 12:54
-
1Did you read the error? If the property has no setter, you cannot set it. – SLaks May 04 '10 at 12:56
-
Possible duplicate of [How to set value for property of an anonymous object?](https://stackoverflow.com/questions/17441420/how-to-set-value-for-property-of-an-anonymous-object) – Jim Aho Jul 16 '19 at 10:43
1 Answers
11
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.

SLaks
- 868,454
- 176
- 1,908
- 1,964