Basically I want to make a reflected version of a class in List So I can iterate through the list, then iterate through its properties as well.
I have gotten to where I can iterate through the properties of 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://learn.microsoft.com/en-us/dotnet/api/system.type.makegenerictype?view=netframework-4.8
Set object property using reflection
any and all help is appreciated.
Why is it so painful to get help on stackoverflow? I mean seriously, if it so easy for you that you took the time to comment, why don't you through up some code and get a free answer?
EDIT: Below will give me an array of classes, but I cannot get the properties enumerated, it just gives me the properties of the array type.
Type reportType = typeof(ReportController).MakeArrayType();
PropertyInfo[] properties = reportType.GetProperties();