Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 2.58 KB

pnpobjectcollection.md

File metadata and controls

52 lines (37 loc) · 2.58 KB
-api-id -api-type
T:Windows.Devices.Enumeration.Pnp.PnpObjectCollection
winrt class

Windows.Devices.Enumeration.Pnp.PnpObjectCollection

-description

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.

-remarks

Collection member lists

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.

Enumerating the collection in C# or Microsoft Visual Basic

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.

Enumerating the collection in C++/WinRT

...
using namespace Windows::Devices::Enumeration::Pnp;
...
void EnumerateCollection(PnpObjectCollection const& collection)
{
    for (PnpObject const& object : collection)
    {
        // ...
    }
}

Also see Collections with C++/WinRT.

-examples

-see-also