Use a collection

You can count, iterate, add, and remove objects in a collection.

Count objects in a collection

The
count
property of a collection is an integer variable that expresses the amount of objects in the collection. This example shows the amount of child nodes in the
Panel1
object:
var myObj = Project.Current.FindObject("Panel1"); Log.Info("The node contains " + myObj.Children.Count + " nodes");

Iterate objects in a collection

You can use the
foreach
instruction to iterate objects in a collection. This example generates an information message for each child node of the
Panel1
object. The result is a list of the
BrowseName
for all child nodes. In the example, a temporary
child
variable is created, which represents a different child node in each cycle.
var myNode = Project.Current.Find("Panel1"); foreach (var child in myNode.Children) Log.Info(child.BrowseName);

Add or remove OPC UA nodes

You can use the
Add()
and
Remove()
methods expressed by collections to add or remove project nodes. See Add or remove nodes.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.