How to group a serial of objects according to timestamp

Posted by Benny on Stack Overflow See other posts from Stack Overflow or by Benny
Published on 2010-03-25T03:01:33Z Indexed on 2010/03/25 3:03 UTC
Read the original article Hit count: 399

Filed under:
|
|
|

I have a serial of object defined as:

public class Foo
{
           public DateTime Time {get;set;}
}

now I want to group objects(IEnumerable<Foo>) according to the time, e.g. I want to group them according to hour or day or month.

for example (group into hour):

group 1(13:00-14:00) : foo1, foo2, foo3
group 2(14:00-15:00): foo4, foo5

How to write LINQ? hope I made myself clear.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about LINQ