1

I am trying to use my USB device inside my C# windows form application, I have found the VID and PID of my device from device manager and they are mentioned like below:

USB\VID_1A86&PID_7523

Now inside my code I have a function named UsbDeviceFinder which gets two integer numbers for PID and VID.

When I use the following code I get an error message which says I should use int numbers inside this function.

public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(1A86, 7523);

It seems like these two numbers are in HEX format. Am I supposed to convert both of them to decimal and then pass them to the function?

Even when I convert these two numbers to Decimal I get the Device not found error. How can I fix this?

Naser.Sadeghi
  • 1,341
  • 1
  • 12
  • 35
  • `int num = int.Parse("1A86", NumberStyles.AllowHexSpecifier);`. It expects Int32 values. – Jimi Aug 08 '18 at 05:25

1 Answers1

1

try this:

public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(0x1A86, 0x7523);
BachPhi
  • 142
  • 11
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/21172758) – Poul Bak Oct 18 '18 at 19:42
  • I disagree with your comment. Since he did not provide what decimal number he used, we could not tell, but I know my solution work, because it worked for me. – BachPhi Oct 20 '18 at 12:50