With the class:
class C
{
int a;
int b;
}
I can do this:
C c = new C();
dynamic D = new ExpandoObject();
D.a = c.a;
D.b = c.b;
But I'm looking for a way to do this automatically.
One way I found is to serialize the class to Json and deserialize it into a dynamic, but it is very slow.
This is to return 'limited' version of classes through an API; and I don't want to code the class building because that means that any updates will require the class building to be updated as well.