IEnumerable and Recursion using yield return

Inside a method that returns IEnumerable<T>, yield return has to return T, not an IEnumerable<T>.

Replace

yield return c.GetDeepControlsByType<T>();

with:

foreach (var x in c.GetDeepControlsByType<T>())
{
  yield return x;
}

Leave a Comment