我有对象的列表结合连续的日期,范围
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"}
如果连续范围既有x又有y?他们是否应该分成两组? – nawfal
它是否必须在Linq?一个简单的循环将更清洁。 –
循环也很好。是的,他们应该在两个不同的组 – RRR