All data in our C # web application is structured in a tree format. Each class that we have extends the BaseObject base class, which itself has a list of BaseObjects called Children. We defined:
public List<BaseObject>.Enumerator GetEnumerator()
{
return Children.GetEnumerator();
}
So, in many places in our code, we look at a tree with something like:
foreach (var rule in this) {
}
When debugging, this foreach loop is skipped in some parts of the code because it says that "this" has no children. If I put a breakpoint in front of the loop and open "this" and open the list of my children, then and only then it will enter the foreach loop.
Does anyone have any reason why this might happen? It drives me crazy.
source
share