如何将此十六进制字符串转换为long? [英] How to convert this hex string into a long?

查看:147
本文介绍了如何将此十六进制字符串转换为long?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:"0xE94C827CEB"用十六进制表示,但作为字符串.

I have: "0xE94C827CEB" in hex but as a string.

哪个是:1002011000043(dd mm yyyy HH mm ss)

Which is: 1002011000043 (dd mm yyyy HH mm ss)

不幸的是,如果我仅以字符串格式进行转换,并且我没有Convert.ToLong("0xE94C827CEB",16)函数,因为我使用的是.NET Micro,所以我不知道如何进行转换框架(同样,没有NumberStyles命名空间可用.)

Unfortunately I don't know how to do the conversion if I only have it in string format, and I don't have a Convert.ToLong("0xE94C827CEB", 16) function because I'm using the .NET Micro Framework (also, don't have NumberStyles namespace available.)

有没有可以为我转换的函数?

Is there a function out there that will convert this for me?

谢谢

推荐答案

我不知道有任何函数可以执行此操作,但是我认为您可以通过拆分十六进制字符串并将每个部分传递给Convert来完成. ToInt32():

I don't know of any function to do it, but I think you can do it quite simply by splitting the hex string and passing each part through Convert.ToInt32():

int part1 = Convert.ToInt32("E9", 16)
int part2 = Convert.ToInt32("4C827CEB", 16) //the last 4 bytes
long result = part1 * 4294967296 + part2  //4294967296 being 2^32. Result = 1002011000043

这篇关于如何将此十六进制字符串转换为long?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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