© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
34 replies
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Convert Uint64 to Hex String Help
C#CC# / help
4y ago
✅ Converting string to DateTimeOffset
C#CC# / help
2y ago
Converting from a string to a generic method invocation
C#CC# / help
3y ago