6.6
The IProfinetDeviceCollection class
6.6.1
Iterating items in the collection
The
class provides the ability to iterate the items in the collection in multiple ways. It also
provides methods to "filter" the items in the collection based on certain criteria. The following
sections describe the functionality available for the collection.
Consider the example code from the ScanNetworkDevices method:
IProfinetDeviceCollection scannedDevices = new IProfinetDeviceCollection();
Result retVal = myNetwork.ScanNetworkDevices(out scannedDevices);
For those programmers that prefer array-like syntax, the items in
accessed as follows:
if (retVal.Succeeded)
{
for (int deviceIdx = 0; deviceIdx < scannedDevices.Count; deviceIdx++)
{
//----------------------------------------------------------
// Each item in the collection is an IProfinetDevice.
//----------------------------------------------------------
IProfinetDevice dev = scannedDevices[deviceIdx];
}
}
The collection also supports iteration using the
the same collection iterated using this syntax:
foreach (IProfinetDevice dev in scannedDevices)
{
//-----------------------------------------------------------
// The variable "dev" now represents the next collection item
//-----------------------------------------------------------
}
SIMATIC Automation Tool V2.1 user guide
Manual, V2.1.1 07/2016, A5E33042676-AC
method outputs an object of type
ScanNetworkDevices
SIMATIC Automation Tool API for .NET framework
6.6 The IProfinetDeviceCollection class
IProfinetDeviceCollection
scannedDevices
syntax. The following example shows
foreach
. This
can be
77