I\'m looking for a way to modify properties on a dynamic
C# 4.0 object with the name of the property known only at runtime.
Is there a way to do something l
To add to Jonas' answer, you don't have to create a new var p. Use this approach instead:
using System;
using System.Dynamic;
class Program
{
static void Main(string[] args)
{
dynamic expando = new ExpandoObject();
((IDictionary)expando)["A"] = "New val 1";
((IDictionary)expando)["B"] = "New val 2";
Console.WriteLine(expando.A);
Console.WriteLine(expando.B);
}
}