AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.4.1" />

 HtmlElementCollection

A general collection containing elements of type IElement.
using AngleSharp.Extensions; using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace AngleSharp.Dom.Collections { internal sealed class HtmlElementCollection : IHtmlCollection<IElement>, IEnumerable<IElement>, IEnumerable { private readonly IEnumerable<IElement> _elements; public int Length => _elements.Count(); public IElement this[int index] { get { if (index < 0) return null; return _elements.Skip(index).FirstOrDefault(); } } public IElement this[string id] { get { return _elements.GetElementById(id); } } public HtmlElementCollection(INode parent, bool deep = true, Predicate<IElement> predicate = null) { _elements = parent.GetElements(deep, predicate); } public HtmlElementCollection(IEnumerable<IElement> elements) { _elements = elements; } public IEnumerator<IElement> GetEnumerator() { return _elements.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return _elements.GetEnumerator(); } } }