C#C
C#3y ago
Dingus

❔ Converting from string into hex literal

I am looking for anyone who can help convert a hex string into a int hex literal. I am creating a usb program using usblibdotnet to find and connect to a device on my computer. In order to connect to the device I need the device PID and VID defined as hexedecimal intergers but how I know to retrieve them from device manager is as a string. If I try to use a simple conversion such as "Convert.ToInt32" or even "Int.Parse" it will convert the number into its literal numerical value rather than keeping it as its hexadecimal value. ex. string = "0x05E0" needs to be int = 0x05E0. Most methods I have found for converting end up making it int = 1504 which isn't wrong but it needs to stay as its literal hexadecimal value in order to work with the library and find the device.
Was this page helpful?