欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Convert byte array to short array in C#

程序员文章站 2022-06-23 16:10:25
Create the short array at half the size of the byte array, and copy the byte data in: It is the fastest method by far. https://*.com/quest ......

Create the short array at half the size of the byte array, and copy the byte data in:

short[] sdata = new short[(int)Math.Ceiling(data.Length / 2)];
Buffer.BlockCopy(data, 0, sdata, 0, data.Length);

It is the fastest method by far.

https://*.com/questions/1104599/convert-byte-array-to-short-array-in-c-sharp