How to add properties in an Expandoobject()?

Asked

Viewed 89 times

-1

I was using the type Dynamic and I’ve been alerted that he has performance issues.

How could I make the code below using ExpandoObject ?

 dynamic dObject = new ExpandoObject();
 dObject.a= a;

And how I could order a list of ExpandoObject ?

With a list of Dynamic I can do this:

dList.OrderBy(minhalista => minhalista.a).ToArray();

But with Expand I can’t.

1 answer

1

ExpandoObject is of the "kind" dynamic.

So you should use it this way anyway.

dynamic dObject = new ExpandoObject();
dObject.A = new ExpandoObject();
dObject.A.Nome = "Paulo";
  • But when doing Dynamic dObject = new Expandoobject(); I’m not using the "type" Dynamic?

  • I think you’re confusing things, ExpandoObject is dynamic

  • What do you mean? It’s an alias?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.