HIDLI库编译错误

HIDLIbrary compile error

HIDLibrary.HidDevice[] HidDeviceList;
HidDevice HidDevice;

// Enumerate the devices with the Vendor Id
// and Product Id of the IT4600
HidDeviceList = HidDevices.Enumerate(VID, PID);

此代码在最后一行编译失败并出现此错误

Error 5 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'HidLibrary.HidDevice[]'. An explicit conversion exists (are you missing a cast?)

我需要什么演员表?

如错误消息所述,您不能将 IEnumerable 分配给数组。您需要调用 ToArray() 将您的 IEnumerable 变成一个数组。由于这是一个非通用实现,您很可能还需要调用 Cast<T>()。它看起来像

HidDeviceList = HidDevices.Enumerate(VID, PID).Cast<HidDevice>().ToArray();