0

I am creating an anonymous object like so:

var myObj = new { ownerId = string.Empty, dateFrom = dateFrom, dateTo = dateTo };

And then, later on in the code (after some other logic) I am trying to assign something different to the ownerId:

myObj.ownerId = accountRec.RingCentralOwnerId;

But I get the error

Property or indexer '...ownerId' cannot be assigned to -- it is read only

Is there any way I can assign a new value to a property of an anonymous type after it's been created?

Matt Spinks
  • 6,380
  • 3
  • 28
  • 47

0 Answers0