本文介绍了将8位字节转换为16位字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i have a byte array.. Each index is having values like 0x01, 0x1D etc.. It can be seen that these values are 8 bit numbers. I want to convert them to 16 bit numbers.  for example, I want this type of result 0x0001 0x001D.  Is there some way to do this in C#?





我的尝试:



将使用BitConverter类。我想得到无符号数字。我不确定BitConverter Class将使用哪种方法。



What I have tried:

BitConverter class will be used. i want to get unsigned numbers. i am not sure which method will be used of BitConverter Class.

推荐答案

ushort[] arr16 = new ushort[arr8.Length];
for (int i = 0; i < arr8.Length; i++)
{
    arr16[i] = arr8[i];
}



这篇关于将8位字节转换为16位字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-24 18:23