if you look it is calling the method FindChildControls in the bottom (inner)foreach statement, since it is coming from a foreach does that make it recursive or iterative?
Thanks!
public static IEnumerable<T> FindChildControls<T>(this ControlCollection controlCollection) where T: class
{
foreach(Control control in controlCollection)
{
if(control is T)
{
yield return control as T;
}
foreach(T type in control.Controls.FindChildControls<T>())
{
yield return type;
}
}
}
This method is recursive because it calls itself on line 9. It also uses iterations (foreach
loops). It's also lazy as it yields results, so unless the caller loops through the enumerator nothing will execute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With