I’m trying to combine a number of List<T> where T:IGetTime (i.e T will always have method getTime()).
Then I’m trying order the items by the DateTime that getTime() returns.
My LINQ looks like this:
public static List<T> Combine(List<T> one, List<T> two, List<T> three) { var result = from IGetTime item in one from IGetTime item2 in two from IGetTime item3 in three select new{ item, item2, item3 }; return result.ToList(); }
I’ve yet to add an orderby. Which should look somthing like this:
var thestream = from T item in this orderby item.getTime() descending select item;
Is there anyway to both combine and order the final list????
Thanks in advance,
Roberto
You’ve got three lists here – what exactly are you trying to order by?
Your cast is incorrect too – the result will be an
IEnumerable<X>whereXis an anonymous type with threeTs in.If the idea is really to concatenate the three lists and then sort, you want: