I have this code:
string IDNumber = "0x0037D70D";
long x = 0x0037D70D; //Working
long x = long.Parse(IDNumber); //Error Input string was not in a correct format.
Required to send the string above (IDNumber) to long y and should maintain the variable format and value typical as its start with 0x.... same as in the IDNumber string
Kindly help me.
Edit:
I have function in DLL file, this function accept one parameter with data type long
If I give this long parameter the value like 0x0037D70D then the function is working correctly and do the required job but if I give the long parameter the value in any other format like 3659533 function is not working
string example1 = "0x0037D70D";
long example2 = 0x0037D70D;
At the end I have the value coming in string format like example1 which I want to convert to be like example2 because if I have the value written like example2 format and saved in long variable then is working
Update: The problem solved, I use this function to communicate with external hardware device and after many times trying the device hangs, I rest the device and the solution advised by @Kirill Polishchuk working for me.
long l = Convert.ToInt64(IDNumber, 16);