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