当前位置: 首页>>代码示例>>C#>>正文


C# DayOfWeek.Contains方法代码示例

本文整理汇总了C#中DayOfWeek.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# DayOfWeek.Contains方法的具体用法?C# DayOfWeek.Contains怎么用?C# DayOfWeek.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DayOfWeek的用法示例。


在下文中一共展示了DayOfWeek.Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BusinessDays

        public static List<int> BusinessDays(DayOfWeek[] WeekEndDays, int Year, int Month)
        {
            List<int> days = new List<int>();

            //Fetch the amount of days in your given month
            int daysInMonth = DateTime.DaysInMonth(Year, Month);

            //Here we create and enumerable from 1 to daysInMonth
            //and ask whether the Datetime object we create belongs to a weekend day,
            //if it doen't add it to our IEumerable<int> collection of days.
            IEnumerable<int> businessDaysInMonth = Enumerable.Range(1, daysInMonth).Where(d => !WeekEndDays.Contains(new DateTime(Year, Month, d).DayOfWeek));

            days.AddRange(businessDaysInMonth);
            return days;
        }
开发者ID:EgyFalseX-Nestle,项目名称:NestleICSales,代码行数:15,代码来源:Uti.cs

示例2: RemoveBusinessDays

        /// <summary>
        /// Remove business days on a DateTime
        /// </summary>
        /// <param name="date">Date to remove days</param>
        /// <param name="days">Days to remove</param>
        /// <param name="businessDays">Business days</param>
        /// <returns>date</returns>
        public static DateTime RemoveBusinessDays(this DateTime date, int days, DayOfWeek[] businessDays)
        {
            days = Math.Abs(days);
            if (businessDays == null || businessDays.Count() == 0)
                businessDays = BaseDateTimeExtensions.GetDefaultBusinessDays();

            var finalCount = 0;
            while (true)
            {
                if (businessDays.Contains(date.DayOfWeek))
                    finalCount++;

                date = date.AddDays(-1);

                if (days == finalCount)
                    break;
            }

            return date;
        }
开发者ID:jornfilho,项目名称:.net-Dev-Utils,代码行数:27,代码来源:Utils.cs

示例3: SetSchedule

		public void SetSchedule(DayOfWeek[] days, HourOfDay fromHour, MinuteOfHour fromMinute, HourOfDay toHour, MinuteOfHour toMinute)
		{
			if (!days.Contains (DayOfWeek.Sunday))
			{
				int num = 0;
				while (num < (int)days.Length)
				{
					if (days[num] < DayOfWeek.Sunday || days[num] > DayOfWeek.Saturday)
					{
						throw new InvalidEnumArgumentException("days", (int)days[num], typeof(DayOfWeek));
					}
					else
					{
						num++;
					}
				}
				for (int i = 0; i < (int)days.Length; i++)
				{
					this.SetSchedule(days[i], fromHour, fromMinute, toHour, toMinute);
				}
				return;
			}
			else
			{
				throw new ArgumentNullException("days");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:ActiveDirectorySchedule.cs

示例4: EndOfBusinessMonth

        /// <summary>
        /// Get end of business month
        /// </summary>
        /// <param name="date">base date</param>
        /// <param name="businessDays">business days list</param>
        /// <returns>End of business month from date</returns>
        public static DateTime EndOfBusinessMonth(this DateTime date, DayOfWeek[] businessDays)
        {
            date = date.EndOfMonth();

            if (businessDays == null || businessDays.Count() == 0)
                businessDays = BaseDateTimeExtensions.GetDefaultBusinessDays();

            while (true)
            {
                if (businessDays.Contains(date.DayOfWeek))
                    return date;

                date = date.AddDays(-1);
            }
        }
开发者ID:jornfilho,项目名称:.net-Dev-Utils,代码行数:21,代码来源:Utils.cs


注:本文中的DayOfWeek.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。