将0x格式的十六进制数转换为整数值 [英] Converting hexadecimal number in 0x format to integer value

查看:187
本文介绍了将0x格式的十六进制数转换为整数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,iam试图将十六进制字符串(例如:0x18da06f1)转换为其相应的整数值:

我尝试了这个但没有解决:

Hi iam trying to convert a hexadecimal string like : 0x18da06f1 to its corresponding integer value:

I tried this but not working out:

string requestId = "0x18da06f1";
           RequestIdentifier = int.Parse(requestId , System.Globalization.NumberStyles.HexNumber);



我提到了此 http://msdn.microsoft.com/en-us/library/zf50za27.aspx [^ ]

这也提到它不会工作.甚至NumberStyles.AllowHexSpecifier似乎也不起作用.

我想知道是否有任何直接支持这种转换的内置方法?我完全可以修剪并使其正常工作.但是我想知道是否有直接使用的api.



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.

推荐答案

Try:
Try:
string requestId = "0x18da06f1";
int RequestIdentifier = Convert.ToInt32(requestId,16);


这篇关于将0x格式的十六进制数转换为整数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆