Search code examples
c#winformswebbrowser-controlgetelementsbytagname

Does GetElementsByTagName() return value on-the-fly?


I have some question about internals. Does GetElementsByTagName() read all the elements requested store on an array and return it or return the value on-the-fly (like using yield)? I hope it's clear


Solution

  • It returns an System.Windows.Forms.HtmlElementCollection, which implements neither IEnumerable nor IEnumerator. That means it doesn't work like yield.

    yield indicates that a method is an iterator. In addition, for a method to be an iterator, its return type must be IEnumerable, IEnumerable<T>, IEnumerator, or IEnumerator<T>.

    See also:

    https://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx