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


C# DateTime.Contains方法代码示例

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


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

示例1: IsWorkingSaturday

    public static bool IsWorkingSaturday(DateTime date)
    {
        DateTime[] holidays =
            new DateTime[] {
                new DateTime(2015,01,24),
                new DateTime(2015,03,21),
                new DateTime(2015,09,12),
                new DateTime(2015,12,12)
            };

        return holidays.Contains(date.Date);
    }
开发者ID:monikaBchvarova,项目名称:C-Sharp,代码行数:12,代码来源:Program.cs

示例2: GetWorkingDays

    public static int GetWorkingDays(DateTime finalDate, DateTime[] holidays)
    {
        var totalDays = 0;
        for (var date = DateTime.Today; date <= finalDate; date = date.AddDays(1))
        {
            if (date.DayOfWeek != DayOfWeek.Saturday
                && date.DayOfWeek != DayOfWeek.Sunday
                && !holidays.Contains(date))
                totalDays++;
        }

        return totalDays;
    }
开发者ID:Elinos,项目名称:TelerikAcademy,代码行数:13,代码来源:WorkingDays.cs

示例3: workdaysCounter

 public static int workdaysCounter(DateTime datePeriodEnd,DateTime[] holidays)
 {
     DateTime now = new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Day,0,0,0);
     DateTime start = now;
     int days = 0;
     while (start <= datePeriodEnd)
     {
         if (start.DayOfWeek != DayOfWeek.Saturday && start.DayOfWeek != DayOfWeek.Sunday&&!holidays.Contains(start))
         {
             ++days;
         }
         start = start.AddDays(1);
     }
     return days;
 }
开发者ID:tddold,项目名称:Telerik-Academy-2,代码行数:15,代码来源:Workdays.cs

示例4: IsHoliday

    public static bool IsHoliday(DateTime date)
    {
        DateTime[] holidays =
        new DateTime[] {
          new DateTime(2015,01,01),
          new DateTime(2015,03,02),
          new DateTime(2015,03,03),
          new DateTime(2015,04,10),
          new DateTime(2015,04,11),
          new DateTime(2015,04,12),
          new DateTime(2015,04,13),
          new DateTime(2015,05,01),
          new DateTime(2015,05,06),
          new DateTime(2015,09,21 ),
          new DateTime(2015,09,22),
          new DateTime(2015,12,24),
          new DateTime(2015,12,25),
          new DateTime(2015,12,26),
          new DateTime(2015,12,31)
          };

        return holidays.Contains(date.Date);
    }
开发者ID:iliantova,项目名称:Telerik-Homework,代码行数:23,代码来源:WorkDay.cs


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