DeviceInformationCollection Kelas

Definisi

Mewakili kumpulan objek DeviceInformation .

public ref class DeviceInformationCollection sealed : IIterable<DeviceInformation ^>, IVectorView<DeviceInformation ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DeviceInformationCollection final : IIterable<DeviceInformation>, IVectorView<DeviceInformation>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DeviceInformationCollection : IEnumerable<DeviceInformation>, IReadOnlyList<DeviceInformation>
Public NotInheritable Class DeviceInformationCollection
Implements IEnumerable(Of DeviceInformation), IReadOnlyList(Of DeviceInformation)
Warisan
Object Platform::Object IInspectable DeviceInformationCollection
Atribut
Penerapan

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)

Contoh

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

Keterangan

Berhasil menyelesaikan FindAllAsync menghasilkan DeviceInformationCollection yang berisi objek DeviceInformation .

Daftar anggota koleksi

Untuk JavaScript, DeviceInformationCollection memiliki anggota yang diperlihatkan dalam daftar anggota. Selain itu, DeviceInformationCollection mendukung properti panjang , anggota Array.prototype, dan menggunakan indeks untuk mengakses item.

Menghitung koleksi di C# atau Microsoft Visual Basic

DeviceInformationCollection dapat dijumlahkan, sehingga Anda dapat menggunakan sintaks khusus bahasa seperti foreach di C# untuk menghitung item dalam koleksi. Pengkompilasi melakukan pengecoran jenis untuk Anda dan Anda tidak perlu mentransmisian secara IEnumerable<DeviceInformation> eksplisit. Jika Anda perlu mentransmisikan secara eksplisit, misalnya jika Anda ingin memanggil GetEnumerator, transmisikan ke IEnumerable<T> dengan batasan DeviceInformation .

Properti

Size

Jumlah objek DeviceInformation dalam koleksi.

Metode

First()

Mendapatkan objek yang dapat melakukan iterasi melalui objek DeviceInformation yang dijumlahkan, dimulai dengan yang pertama.

GetAt(UInt32)

Mendapatkan objek DeviceInformation pada indeks yang ditentukan.

GetMany(UInt32, DeviceInformation[])

Mendapatkan berbagai objek DeviceInformation .

IndexOf(DeviceInformation, UInt32)

Mengembalikan indeks objek DeviceInformation yang ditentukan dalam koleksi.

Berlaku untuk