NodeState rootNode = /* get the root NodeState */; IEnumerablechildren = rootNode.GetChildren(); foreach (NodeState childNode in children) { /* Do something with the child NodeState */ }
NodeState parentNode = /* get a parent NodeState */; IEnumerableThis example utilizes the NodeState.GetChildren method to determine whether a node has any children. If it does, it performs some action, and if it doesn't, it performs a different action. Package/library: The package/library that is most likely to include the NodeState.GetChildren method is a tree or graph library such as QuickGraph or GraphSharp.children = parentNode.GetChildren(); if (children.Any()) { // If the node has children /* Do something */ } else { // If the node has no children /* Do something else */ }