All Dates Between as IEnumerable - CSharp System

CSharp examples for System:DateTime Calculate

Description

All Dates Between as IEnumerable

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w w  w  .  j  av  a 2s .  c o m*/

public class Main{
        static IEnumerable<DateTime> AllDatesBetween(DateTime start, DateTime end)
        {
            for (var day = start.Date; day <= end; day = day.AddDays(1))
                yield return day;
        }
}

Related Tutorials