Consider the following:
var o = new { Foo = "foo", Bar = "bar" };
This instance is read-only, since the anonymous type doesn't implement setters like a class does:
public class O
{
public String Foo { get; set; }
public String Bar { get; set; }
}
Is it possible to "open up" the anonymous instance and allow it's properties to be altered? Preferably in fewer characters than it would take to create a class.
I'm thinking perhaps this can be done with an extension method on Object; o.SetProperty(o.Foo, "foo!");
, if you can't implement setters in-line at the construction of the object.