I have a List of objects
public class sample
{
public DateTime Date;
public string content;
}
I want to be able to create a list of new objects
public class sampleWithIntervals
{
public DateTime startDate;
public DateTime endDate;
public string content;
}
The sample objects should be grouped into intervals based on the content. The intervals can include only those dates that are included in the original sample list.
I dont know how to do this in Linq.
Sample data:
{"10/1/2013", "x"}
{"10/2/2013", "x"}
{"10/2/2013", "y"}
{"10/3/2013", "x"}
{"10/3/2013", "y"}
{"10/10/2013", "x"}
{"10/11/2013", "x"}
{"10/15/2013", "y"}
{"10/16/2013", "y"}
{"10/20/2013", "y"}
This should give me
{"10/1/2013","10/3/2013", "x"}
{"10/2/2013","10/3/2013", "y"}
{"10/10/2013","10/11/2013", "x"}
{"10/15/2013","10/16/2013", "y"}
{"10/20/2013","10/20/2013", "y"}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…