C# select elements from IList
Posted
by user313884
on Stack Overflow
See other posts from Stack Overflow
or by user313884
Published on 2010-04-11T11:51:39Z
Indexed on
2010/04/11
11:53 UTC
Read the original article
Hit count: 1386
I have a list of objects: IList<
O>
O has several properties but only two of them are relevant: Date and Duration
I want to "split" the list into several lists that contain only the objects that have matching Date and Duration Properties.
Example:
InitialList:
0- Date==1, Duration==7
1- Date==1, Duration==7
2- Date==2, Duration==7
3- Date==2, Duration==7
4- Date==2, Duration==14
5- Date==2, Duration==14
Desired result:
IList<
IList<
O>
>:
0-
0- Date==1, Duration==7
1- Date==1, Duration==7
1-
0- Date==2, Duration==7
1- Date==2, Duration==7
2-
0- Date==2, Duration==14
1- Date==2, Duration==14
i know this can be done with some linq selects but am not sure how.
thanks for the help.
© Stack Overflow or respective owner