-api-id | -api-type |
---|---|
T:Windows.Devices.Enumeration.Pnp.PnpObjectCollection |
winrt class |
Important
We no longer recommend that you use the types in the Windows.Devices.Enumeration.Pnp namespace. Instead, the types in the Windows.Devices.Enumeration namespace implement a modern, and better maintained, superset of the functionality of Windows.Devices.Enumeration.Pnp.
The alternative to PnpObjectType is the Windows.Devices.Enumeration.DeviceInformationKind enum, which you can pass as a parameter to Windows.Devices.Enumeration APIs. For example, instead of using PnpObjectType when you create a PnpObjectWatcher, use DeviceInformationKind when you create a DeviceWatcher.
Represents an iterable collection of Pnp device objects.
For JavaScript, PnpObjectCollection has the members shown in the member lists. In addition, PnpObjectCollection supports a length property, members of Array.prototype, and using an index to access items.
PnpObjectCollection is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the collection. The compiler does the type-casting for you and you won't need to cast to IEnumerable<PnpObject>
explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with a PnpObject constraint.
...
using namespace Windows::Devices::Enumeration::Pnp;
...
void EnumerateCollection(PnpObjectCollection const& collection)
{
for (PnpObject const& object : collection)
{
// ...
}
}
Also see Collections with C++/WinRT.