foreach
- Last UpdatedApr 24, 2024
- 1 minute read
The foreach statement enumerates the elements of a collection and executes its body for each element of the collection. If the collection is empty, the body of the foreach statement isn’t executed, whereas if condition is null an exception is thrown.
Example code
static void testForeach()
{
foreach(string s in Runtime::Scene.EnumerateNodes("all"))
{
Runtime::Environment.Print(s);
}
}
//Output displays the list of the name of nodes in the scene returned by EnumerateNodes(“all”) one by one in a new line