Click here to Skip to main content
15,888,241 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi iam trying to convert a hexadecimal string like : 0x18da06f1 to its corresponding integer value:

I tried this but not working out:
C#
string requestId = "0x18da06f1";
           RequestIdentifier = int.Parse(requestId , System.Globalization.NumberStyles.HexNumber);


I referred this http://msdn.microsoft.com/en-us/library/zf50za27.aspx[^]

This also mentions that it wont work. Even NumberStyles.AllowHexSpecifier doesnt seem to work.

I want to know is there any inbuilt method that supports such conversion directly? Altough i can trim it and make it work. But i want to know if there is any api that works directly.
Posted
Comments
BoxyBrown 18-Aug-11 5:52am    
sorry for wrong solution.

1 solution

Try:
C#
string requestId = "0x18da06f1";
int RequestIdentifier = Convert.ToInt32(requestId,16);
 
Share this answer
 
Comments
glued-to-code 18-Aug-11 5:45am    
Thanks a lot.
OriginalGriff 18-Aug-11 5:50am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900