niisar
3/4/2016 - 7:14 PM

Algorithm to find next 10 Business Day

Algorithm to find next 10 Business Day

using System;
using System.Collections.Generic;
using System.Linq;

namespace Rextester
{
    
    public class Program
    {
        private static DateTime Calculate(DateTime today,int toDays)
        {
            DateTime currentDate = today;   
            int iday = 0;
            for (int i = 1; i < toDays+1; i++)
            {
                if ((int)currentDate.DayOfWeek >= 6 || (int)currentDate.DayOfWeek == 0){
                    iday = iday + 1;
                }else
                {
                    
                }
                currentDate = currentDate.AddDays(1);
            }
            return (today).AddDays(Convert.ToDouble(iday+toDays));
        }
        
        public static void Main(string[] args)
        {
            Console.WriteLine(Calculate(DateTime.Now,10));
        }
    }
}