DeviceInformationCollection DeviceInformationCollection DeviceInformationCollection DeviceInformationCollection Class

Represents a collection of DeviceInformation objects.

Syntax

Declaration

public sealed class DeviceInformationCollectionpublic sealed class DeviceInformationCollectionPublic NotInheritable Class DeviceInformationCollectionpublic sealed class DeviceInformationCollection

Remarks

Successful completion of FindAllAsync(String) 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.

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;
}

Properties summary

The number of DeviceInformation objects in the collection.

Methods summary

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

Gets the DeviceInformation object at the specified index.

Gets a range of DeviceInformation objects.

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

Properties

  • Size
    Size
    Size
    Size

    The number of DeviceInformation objects in the collection.

    public uint Size { get; }public uint Size { get; }Public ReadOnly Property Size As uintpublic uint Size { get; }

    Property Value

Methods

  • First()
    First()
    First()
    First()

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

    public IIterator<DeviceInformation> First()public IIterator<DeviceInformation> First()Public Function First() As IIterator( Of DeviceInformation )public IIterator<DeviceInformation> First()

    Returns

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

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

    Gets the DeviceInformation object at the specified index.

    public DeviceInformation GetAt(UInt32 index)public DeviceInformation GetAt(UInt32 index)Public Function GetAt(index As UInt32) As DeviceInformationpublic DeviceInformation GetAt(UInt32 index)

    Parameters

    • index
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The index.

    Returns

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

    Gets a range of DeviceInformation objects.

    public uint GetMany(UInt32 startIndex, DeviceInformation[] items)public uint GetMany(UInt32 startIndex, DeviceInformation[] items)Public Function GetMany(startIndex As UInt32, items As DeviceInformation[]) As uintpublic uint GetMany(UInt32 startIndex, DeviceInformation[] items)

    Parameters

    • startIndex
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The index at which to start retrieving DeviceInformation objects.

    • items
      Windows.Devices.Enumeration.DeviceInformation[]
      Windows.Devices.Enumeration.DeviceInformation[]
      Windows.Devices.Enumeration.DeviceInformation[]
      Windows.Devices.Enumeration.DeviceInformation[]

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

    Returns

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

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

    public bool IndexOf(DeviceInformation value, UInt32 index)public bool IndexOf(DeviceInformation value, UInt32 index)Public Function IndexOf(value As DeviceInformation, index As UInt32) As boolpublic bool IndexOf(DeviceInformation value, UInt32 index)

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      true if the method succeeded; otherwise, false.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.Devices.Enumeration.dll