I have a method that receives a list of objects:
private void escribe(List<object> lista)
that a priori I do not know what class they are and I want to know at the time of execution the properties of each of the objects within the list.
I've tried with:
Type type = lista.GetType();
var PropertyInfos = lista.GetType().GetProperties();
I've also tried with:
Type tip = lista.GetType();
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>))
{
var itemType = type.GetGenericArguments()[0];
}
But I can not recover the properties of the object in question. Greetings and thanks for the help.
Edit: I add information about the class I'm tested with, although I really want it to work for anyone.
public class Prueba
{
string prop1;
int prop2;
bool prop3;
float prop4;
//List<string> prop5;
object prop6;}
And all these fields are transformed into properties with the first letter in capital letters