implement canviewall method + C# code example

Example: 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;
    }
}