DeviceInformationCollection 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 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)
		- 继承
 
- 属性
 
- 实现
 
Windows 要求
| 设备系列 | 
					 
							Windows 10 (在 10.0.10240.0 中引入) 
				 | 
			
| API contract | 
					 
							Windows.Foundation.UniversalApiContract (在 v1.0 中引入) 
				 | 
			
示例
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;
}
	注解
FindAllAsync 的成功完成将生成包含 DeviceInformation 对象的 DeviceInformationCollection。
集合成员列表
对于 JavaScript,DeviceInformationCollection 具有成员列表中显示的成员。 此外,DeviceInformationCollection 支持 length 属性、 Array.prototype 的成员以及使用索引来访问项。
枚举 C# 或 Microsoft Visual Basic 中的集合
DeviceInformationCollection 是可枚举的,因此可以使用特定于语言的语法(如 C# 中的 foreach )来枚举集合中的项。 编译器为你执行类型强制转换,你无需显式转换为 IEnumerable<DeviceInformation> 。 如果需要显式强制转换(例如,如果要调用 GetEnumerator),请使用 DeviceInformation 约束强制转换为 IEnumerable<T>。
属性
| Size | 
		 集合中的 DeviceInformation 对象数。  | 
        	
方法
| First() | 
		 获取一个对象,该对象可循环访问枚举的 DeviceInformation 对象,从第一个 对象开始。  | 
        	
| GetAt(UInt32) | 
		 获取指定索引处的 DeviceInformation 对象。  | 
        	
| GetMany(UInt32, DeviceInformation[]) | 
		 获取 DeviceInformation 对象的范围。  | 
        	
| IndexOf(DeviceInformation, UInt32) | 
		 返回集合中指定 DeviceInformation 对象的索引。  |