Get Days Of Week After - CSharp System

CSharp examples for System:DateTime Week

Description

Get Days Of Week After

Demo Code


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

public class Main{
        public static IEnumerable<DateTime> GetDaysOfWeekAfter(this DateTime dateTime, uint days = 6, uint daysToSkip = 1, bool wrap = false)
        {
            var daysOfWeek = new List<DateTime>((int)days);
            for (uint i = daysToSkip; i < days + daysToSkip; i++)
            {
                var newDateTime = dateTime.AddDays(i);
                if (wrap == false && dateTime.DayOfWeek == newDateTime.DayOfWeek)
                {
                    break;
                }

                daysOfWeek.Add(newDateTime);
            }

            return daysOfWeek;
        }
}

Related Tutorials