lundi 12 novembre 2018

C# Build anonymous object dynamically

In C# I can easily create an anonymous object like this at the compile time:

var items = new {
 Price = 2000,
 Description = "",
 Locations = new List<string> { "", "" }  
};

My question is, it's possible to create this object at the runtime ? I've heard of emit/meta programming, but I don't know if it helps here.

Noting that these objects will be created inside a for loop (100 items or more), so I recommend techniques that allow type caching.

Thanks.





Aucun commentaire:

Enregistrer un commentaire