Device​Information​Collection Device​Information​Collection Device​Information​Collection Class

Definition

Represents a collection of DeviceInformation objects.

public : sealed class DeviceInformationCollection : IIterable, IVectorViewpublic sealed class DeviceInformationCollection : IEnumerable, IReadOnlyListPublic NotInheritable Class DeviceInformationCollection Implements IEnumerable, IReadOnlyList
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples


var DeviceInformation = Enumeration.DeviceInformation;
DeviceInformation.findAllAsync(deviceClass).then(
    successCallback, 
    errorCallback
);

// Handles successful completion of the findAllAsync method.
function successCallback(deviceInformationCollection) {
    var numDevices = deviceInformationCollection.length;
    document.getElementById("statusMessage").innerHTML = 
        numDevices + " device interface(s) found";
    if (numDevices) {
        for (var i = 0; i < numDevices; i++) {
            printFriendlyNameAndID(deviceInformationCollection[i], 
                document.getElementById("Output"));
        }
    } else {
        document.getElementById("statusMessage").innerHTML = "No devices found";
    }
}

// Handles an error completion of the findAllAsync method.
function errorCallback(e) {
    document.getElementById("statusMessage").innerHTML = 
        "Failed to find devices, error: " + e.message;
}

Remarks

Successful completion of FindAllAsync results in a DeviceInformationCollection containing DeviceInformation objects.

Collection member lists

For JavaScript, DeviceInformationCollection has the members shown in the member lists. In addition, DeviceInformationCollection supports a length property, members of Array.prototype, and using an index to access items.

Enumerating the collection in C# or Microsoft Visual Basic

DeviceInformationCollection 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<DeviceInformation> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with a DeviceInformation constraint.

Properties

Item[Int32] Item[Int32] Item[Int32]

Gets the element at the specified index in the read-only list.

This member is not implemented in C++T this[int index] { get; }ReadOnly Property Item(index As Integer) As T
Parameters
index

The zero-based index of the element to get.

Value
T T T

The element at the specified index in the read-only list.

Attributes

Size Size Size

The number of DeviceInformation objects in the collection.

public : unsigned short Size { get; }This member is not implemented in C#This member is not implemented in VB.Net
Value
unsigned short uint uint

The number of DeviceInformation objects in the collection.

Attributes

Methods

First() First() First()

Gets an object that can iterate through the enumerated DeviceInformation objects, starting with the first.

public : IIterator<DeviceInformation> First()This member is not implemented in C#This member is not implemented in VB.Net
Returns

An object that can iterate through the enumerated devices, starting with the first.

Attributes

GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)

Gets the DeviceInformation object at the specified index.

public : DeviceInformation GetAt(unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

The index.

Returns
Attributes

GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the collection.

This member is not implemented in C++IEnumerator<T> GetEnumerator()Function GetEnumerator As IEnumerator(Of T)
Returns

An enumerator that can be used to iterate through the collection.

Attributes

GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[])

Gets a range of DeviceInformation objects.

public : unsigned short GetMany(unsigned int startIndex, DeviceInformation[] items)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
startIndex
unsigned int UInt32 UInt32

The index at which to start retrieving DeviceInformation objects.

items
DeviceInformation[] DeviceInformation[] DeviceInformation[]

The array of DeviceInformation objects starting at the index specified by startIndex.

Returns
unsigned short uint uint

The number of DeviceInformation objects returned.

Attributes

IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32)

Returns the index of the specified DeviceInformation object in the collection.

public : PlatForm::Boolean IndexOf(DeviceInformation value, unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

The index.

Returns
PlatForm::Boolean bool bool

true if the method succeeded; otherwise, false.

Attributes