本文整理汇总了C#中DayOfWeek.Count方法的典型用法代码示例。如果您正苦于以下问题:C# DayOfWeek.Count方法的具体用法?C# DayOfWeek.Count怎么用?C# DayOfWeek.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DayOfWeek
的用法示例。
在下文中一共展示了DayOfWeek.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: SetDefaultBusinessDays
/// <summary>
/// Set default business days list
/// </summary>
public static void SetDefaultBusinessDays(DayOfWeek[] businessDays)
{
if (businessDays != null && businessDays.Count() > 0)
Instance.BusinessDays = businessDays;
}
示例3: 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);
}
}