Each Day from a range - CSharp System

CSharp examples for System:DateTime Day

Description

Each Day from a range

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w  w w.  ja v a  2  s. c  om

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

Related Tutorials