我有一个对象列表
public class sample
{
public DateTime Date;
public string content;
}
Run Code Online (Sandbox Code Playgroud)
我希望能够创建一个新对象列表
public class sampleWithIntervals
{
public DateTime startDate;
public DateTime endDate;
public string content;
}
Run Code Online (Sandbox Code Playgroud)
应根据内容将样本对象分组为间隔.间隔可以仅包括原始样本列表中包含的那些日期.我不知道如何在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"}
Run Code Online (Sandbox Code Playgroud)