I have seen this syntax in MSDN: yield break, but I don\'t know what it does. Does anyone know?
Tells the iterator that it's reached the end.
As an example:
public interface INode
{
IEnumerable GetChildren();
}
public class NodeWithTenChildren : INode
{
private Node[] m_children = new Node[10];
public IEnumerable GetChildren()
{
for( int n = 0; n < 10; ++n )
{
yield return m_children[ n ];
}
}
}
public class NodeWithNoChildren : INode
{
public IEnumerable GetChildren()
{
yield break;
}
}