如何从课程表列表中找到空闲时间段? [英] How Do I Can Found Free Time Slots From The Classes Schedule List?

查看:171
本文介绍了如何从课程表列表中找到空闲时间段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的课程安排列表,其中包含ClassStartTime& ClassEndTime

列表示例:



this is my classes schedule list containing "ClassStartTime" & "ClassEndTime"
List Example:

List<Tuple<TimeSpan, TimeSpan>> ScheduleList = new List<Tuple<TimeSpan, TimeSpan>>();
          ScheduleList.Add(Tuple.Create<TimeSpan, TimeSpan>(TimeSpan.Parse("08:00:00"), TimeSpan.Parse("09:30:00")));
          ScheduleList.Add(Tuple.Create<TimeSpan, TimeSpan>(TimeSpan.Parse("10:30:00"), TimeSpan.Parse("11:00:00")));
          ScheduleList.Add(Tuple.Create<TimeSpan, TimeSpan>(TimeSpan.Parse("11:30:00"), TimeSpan.Parse("12:30:00")));
          ScheduleList.Add(Tuple.Create<TimeSpan, TimeSpan>(TimeSpan.Parse("13:30:00"), TimeSpan.Parse("13:50:00")));
          ScheduleList.Add(Tuple.Create<TimeSpan, TimeSpan>(TimeSpan.Parse("14:30:00"), TimeSpan.Parse("51:00:00")));
          ScheduleList.Add(Tuple.Create<TimeSpan, TimeSpan>(TimeSpan.Parse("15:30:00"), TimeSpan.Parse("16:00:00")));





现在的问题是我如何从这个列表中找到空闲时间段(9号之间没有课程) :30到10:30)..



now the question is that how do i found free time slot from this list like(there is no class between 9:30 to 10:30)..

推荐答案

你可能想开始考虑'遍历'/迭代这个列表,比较一个时期的结束与开始下一个并看看差异是否>一段时间表示一个免费插槽



你可以查看



.NET时间段库 [ ^ ]



关于术语的一些想法/您需要考虑的事项
you would probably want to start thinking about 'traversing'/iterating this list, comparing the end of one period with the start of the next and seeing if the difference is > some duration that would indicate a free slot

you could have a look at

Time Period Library for .NET[^]

for some thoughts on terminology/what you'd need to consider


这篇关于如何从课程表列表中找到空闲时间段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆