What I want but instead of doing
var carsPartial = cars.Select("new(name, year)").ToList();
I want to do this:
var carsPartial = cars.Select<car>("new car(name, year)").ToList<car>();
Thanks again and ask for clarification if needed.
car class:
public class car
{
public string name { get; set; }
public int year { get; set; }
}
What is in cars: a bunch of cars data with names and years sort of like a database.
Do you know the generic part of the Select at compile time? In your example, is known, or is that also 'dynamic'? If it is known, then you should be able to do (didn't test it):
var carsPartial = cars.Select("new car(name, year)").Cast<car>().ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With