包含十六进制值到十进制值的字节数组转换 [英] Conversion of byte array containing hex values to decimal values

查看:255
本文介绍了包含十六进制值到十进制值的字节数组转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#。在这里应用,我想转换包含十六进制值转换为十进制values​​.Suppose我有一个字节数组作为

I am making application in c#.Here i want to convert a byte array containing hex values to decimal values.Suppose i have one byte array as

array[0]=0X4E;
array[1]=0X5E;
array[2]=0X75;
array[3]=0X49;

在这里,我想给十六进制数组转换为十进制数,像我想先来连接所有字节值4E5E7549和数量decimal.I的是转换后不用想每个单独的十六进制数转换为十进制decimal.The相当于这十六进制数是1314813257.So请帮助me.Thanks提前。

Here i want to convert that hex array to decimal number like i want to concatenate first all bytes values as 4E5E7549 and after that conversion of that number to decimal.I dont want to convert each separate hex number to decimal.The decimal equivalent of that hex number is 1314813257.So please help me.Thanks in advance.

推荐答案

BitConverter.ToInt32 方法是做到这一点的好办法

The BitConverter.ToInt32 method is a good way to do this

if (BitConverter.IsLittleEndian)
    Array.Reverse(array); //need the bytes in the reverse order
int value = BitConverter.ToInt32(array, 0);

这篇关于包含十六进制值到十进制值的字节数组转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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