using System; using System.Collections.Generic; using System.Linq; namespace VCommon { public static class DateTimeExtensionMethod { public static DateTime[] GetBetweenMonths(this DateTime begin, DateTime end) { return Enumerable.Range(0, (end.Year - begin.Year) * 12 + (end.Month - begin.Month + 1)) .Select(p => new DateTime(begin.Year, begin.Month, 1).AddMonths(p)) .ToArray(); } public static DateTime[] GetBetweenDays(this DateTime begin, DateTime end) { var allDays = new List(); for (DateTime date = begin; date <= end; date = date.AddDays(1)) allDays.Add(date); return allDays.ToArray(); } } }