WorkingTimeCollection.Remove
Contents
[
Hide
]WorkingTimeCollection.Remove method
Removes WorkingTime
instance from this collection.
public bool Remove(WorkingTime item)
Parameter | Type | Description |
---|---|---|
item | WorkingTime | The item to remove. |
Return Value
true if WorkingTime instance was successfully removed from this collection; otherwise, false.
Examples
Shows how to work with working time collection.
var project = new Project();
var calendar = project.Calendars.Add("Custom Calendar");
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday));
var saturdayWorkingTimes = new List<WorkingTime>
{
new WorkingTime(8, 12),
new WorkingTime(13, 15)
};
var saturday = new WeekDay(DayType.Saturday);
foreach (var time in saturdayWorkingTimes)
{
saturday.WorkingTimes.Add(time);
}
// print working times of Saturday
Console.WriteLine("Saturday working period number: " + saturday.WorkingTimes.Count);
foreach (var time in saturday.WorkingTimes)
{
Console.WriteLine("From Time: " + time.From);
Console.WriteLine("To Time: " + time.To);
}
Console.WriteLine();
var sundayWorkingTimes = new List<WorkingTime>
{
new WorkingTime(10, 15)
};
var sunday = new WeekDay(DayType.Sunday, sundayWorkingTimes);
// print working times of sunday
List<WorkingTime> workingTimes = sunday.WorkingTimes.ToList();
Console.WriteLine("Sunday working period number: " + workingTimes.Count);
for (var index = 0; index < workingTimes.Count; index++)
{
var time = workingTimes[index];
Console.WriteLine("From Time: " + time.From);
Console.WriteLine("To Time: " + time.To);
}
Console.WriteLine();
calendar.WeekDays.Add(saturday);
calendar.WeekDays.Add(sunday);
foreach (var day in calendar.WeekDays)
{
Console.WriteLine(day.DayType + ": ");
// You can further traverse through working times and display these
foreach (var workingTime in day.WorkingTimes)
{
Console.WriteLine(workingTime.From);
Console.WriteLine(workingTime.To);
}
Console.WriteLine();
}
See Also
- class WorkingTime
- class WorkingTimeCollection
- namespace Aspose.Tasks
- assembly Aspose.Tasks