I am wanting to get the average of a column. I can get it working like:
IEnumerable results = defaultView.Select(args);
Decimal amount = results.Cast<Fees>().Average(x => x.Fee);
where results is a collection of System.Collections.Generic.List`1 objects. However results is not always the same object because something else may be returned.
It is always in the structure of x objects with 5-10 values each.
I was hoping for a generic way to iterate over the data such as results[0][2] but can’t find a way to access this data without using the strongly typed example above. Any ideas?
Your best bet is to create interfaces for the properties that are shared amongst different classes:
Then you could apply this interface to all the classes that have a Fee property: