Answers for "implement canviewall method + C#"

C#
0

implement canviewall method + C#

public static IEnumerable<Meeting[]> Overlappings(this IEnumerable<Meeting> meetings)
{
    var first = (Meeting)null;
    var orderedMeetings = meetings.OrderBy(m => m.Start);
    var checkedMeetings = new List<Meeting>();
    
    foreach (var meeting in orderedMeetings)
    {
        if (first != null)
        {
            checkedMeetings.Add(first);
            var uncheckedMeetings = orderedMeetings.Where(x => (x.Start >= first.Start && !(x == first)) && !checkedMeetings.Any(m => m == x));
            
            foreach (var meet in uncheckedMeetings)
            {
                if (first.OverlapsWith(meet))
                {
                    yield return new[] { first, meet };
                }
            }
        }
        first = meeting;
    }
}
Posted by: Guest on January-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language