Basically I want to make a reflected version of a class in List<> form so I can iterate through the list, then do the same thing on its properties so I can iterate through its properties as well.
I have gotten to where I can iterate through a single instance of a class, but I cant seem to figure out a solution for a List<> of reflected classes.
basically I want List[i].property[j] = GetData(c);
Below is the code I was messing with to get the List of reflected classes and their properties.
Type reportType = typeof(ReportController);
Type reportListType = typeof(List<ReportController>);
PropertyInfo[] properties = reportListType.GetProperties();
I also tried =typeof(List<>);
but passing in the reportType, for whatever reason the formatting won't show it on SO.
Below is the references I have accessed.
C# instantiate generic List from reflected Type
https://docs.microsoft.com/en-us/dotnet/api/system.type.makegenerictype?view=netframework-4.8
Set object property using reflection
any and all help is appreciated.
Aucun commentaire:
Enregistrer un commentaire