我有一个对象列表
public class sample
{
public DateTime Date;
public string content;
}
我希望能够创建一个新对象列表
public class sampleWithIntervals
{
public DateTime startDate;
public DateTime endDate;
public string content;
}
样本对象应根据内容分组为间隔。间隔只能包括原始样本列表中包含的那些日期。我不知道如何在 Linq 中做到这一点。
样本数据:
{"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"}