Currently, I am struggling to convert List<object>
to object
.
How should look like is each item from the list, to become a property of the object
. I think here I should look for the dynamic generation of classes.
An example: The list:
List<object> objects = new List<object>{ FirstName = "Nick", SecondName = "John" };
Should be converted to object/class:
class ConvertedObjects
{
public string FirstName {get;set;}
public string SecondName {get;set;
}
Here I guess I have to go deeper in Reflection, but I am not sure if there is any workaround of that?
The trick here is that every time
List<object>
will have different values, so I cannot hard-code a class and then only set properties.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire