本文整理汇总了C#中DateRange.ForEachWeek方法的典型用法代码示例。如果您正苦于以下问题:C# DateRange.ForEachWeek方法的具体用法?C# DateRange.ForEachWeek怎么用?C# DateRange.ForEachWeek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateRange
的用法示例。
在下文中一共展示了DateRange.ForEachWeek方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForEachWeek_Full
public void ForEachWeek_Full()
{
int count = 0;
int weekCount = 2;
DateRange[] weeks = new DateRange[weekCount];
DateTime weekEnd = new DateTime(2005, 12, 17);
DateTime weekStart = new DateTime(2005, 12, 4);
DateRange range = new DateRange(weekStart, weekEnd);
weeks[0] = new DateRange(weekStart,new DateTime(2005, 12, 10));
weeks[1] = new DateRange(new DateTime(2005, 12,11), weekEnd);
range.ForEachWeek(delegate(DateRange week)
{
Assert.AreEqual(weeks[count], week);
count++;
});
Assert.AreEqual(weekCount, count);
}
示例2: ForEachWeek_Partial
public void ForEachWeek_Partial()
{
int count = 0;
int weekCount = 1;
DateRange[] weeks = new DateRange[weekCount];
DateRange range = new DateRange(start, start);
weeks[0] = new DateRange(start, start);
range.ForEachWeek(delegate(DateRange week)
{
Assert.AreEqual(weeks[count], week);
count++;
});
Assert.AreEqual(weekCount, count);
}
示例3: ForEachWeek
public void ForEachWeek()
{
int count = 0;
int weekCount = 12;
DateRange[] weeks = new DateRange[weekCount];
DateRange range = new DateRange(start, end);
weeks[0] = new DateRange(start, start);
DateTime current = start.AddDays(1);
for (int i = 1; i < weekCount-1; i++)
{
weeks[i] = new DateRange(current, current.AddDays(6));
current = current.AddDays(7);
}
weeks[weekCount - 1] = new DateRange(current, end);
range.ForEachWeek(delegate(DateRange week)
{
Assert.AreEqual(weeks[count], week);
count++;
});
Assert.AreEqual(weekCount, count);
}