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://stackoverflow.com/questions/1104599/convert-byte-array-to-short-array-in-c-sharp

Convert byte array to short array in C#的更多相关文章

  1. Array.prototype.slice && Array.prototype.splice 用法阐述

    目的 对于这两个数组操作接口,由于不理解, 往往被误用, 或者不知道如何使用.本文尝试给出容易理解的阐述. 数组 什么是数组? 数组是一个基本的数据结构, 是一个在内存中依照线性方式组织元素的方式, ...

  2. Array.length vs Array.prototype.length

    I found that both the Array Object and Array.prototype have the length property. I am confused on us ...

  3. sklearn中报错ValueError: Expected 2D array, got 1D array instead:

    from sklearn.linear_model import LinearRegression lr = LinearRegression() print(tr_x.shape,tr_y.shap ...

  4. From Ruby array to JS array in Rails- 'quote'?

    From Ruby array to JS array in Rails- 'quote'? <%= raw @location_list.as_json %>

  5. ES6数组的扩展--Array.from()和Array.of()

    一. Array.from() : 将伪数组对象或可遍历对象转换为真数组 1.何为伪数组 如果一个对象的所有键名都是正整数或零,并且有length属性,那么这个对象就很像数组,语法上称为"类 ...

  6. es6 --数组--Array.from() 、Array.isArray()、Array.of()、find()、findIndex()、fill()、entries() 、keys() ,values()

    将两类对象转为真正的数组 Array.from()方法用于将两类对象转为真正的数组:类似数组的对象(array-like object)和可遍历(iterable)的对象(包括ES6新增的数据结构Se ...

  7. Array.of()和Array()区别

    Array.of方法用于将一组值,转换为数组. Array.of(3, 11, 8) // [3,11,8] Array.of(3) // [3] Array.of(3).length // 1 这个 ...

  8. [Python] Indexing An Array With Another Array with numpy

    NumPy Reference: Indexing Integer array indexing: Select array elements with another array def index ...

  9. JavaScript Array vs new Array区别

    规范说明 When Array is called as a function rather than as a constructor, it creates and initialises a n ...

  10. 决策树python建模中的坑 :ValueError: Expected 2D array, got 1D array instead:

    决策树python建模中的坑 代码 #coding=utf-8 from sklearn.feature_extraction import DictVectorizerimport csvfrom ...

随机推荐

  1. 2.3k Star!强得不像开源的问卷调研平台

    产品:咱们的新功能上线了,得问问用户的意见,做个调研问卷吧! 运营:对啊,用户意见很重要,我们要认真听取反馈! 领导:问卷别搞得像考试.我们要的是真实的声音,而不是让用户头疼的题目. 程序员:收到! ...

  2. maven 分离打包的技术

    1.概要 我们在构建springboot 程序的时候,可以将所有的文件打包成一个大的文件,这个使用起来还是很方便的,但是有些情况下不是很方便,比如 程序需要经常更新的时候,通过网络传输就比较慢,还有比 ...

  3. Cython二进制逆向系列(一) 初识Cython

    Cython二进制逆向系列(一) 初识Cython   众所周知,Python类题目最难的一种就是使用Cython工具将py源码转换为二进制文件.此类题目相比于直接由Cpython编译而成的类字节码文 ...

  4. Python 2.7 十六进制字符数组 转 字符串 (字符是Unicode字符)

    有一串十六进制数据,是Uncode字符. import struct strhex='003100310031' buf = strhex.decode("hex") value= ...

  5. COSBrowser 移动端——随时随地查看管理数据

    外出身边没有电脑,需要查看管理数据怎么办? 出现紧急情况,需要快速停止某个 bucket 对外访问,怎么办? 个人用户仅作为网盘使用,需要方便轻量的管理工具,怎么办? 不用着急,COSBrowser ...

  6. Netty内存池泄漏问题

    为了提升消息接收和发送性能,Netty针对ByteBuf的申请和释放采用池化技术,通过PooledByteBufAllocator可以创建基于内存池分配的ByteBuf对象,这样就避免了每次消息读写都 ...

  7. jenkins build

    clean test org.jacoco:jacoco-maven-plugin:0.8.5:prepare-agent org.owasp:dependency-check-maven:5.3.0 ...

  8. WPFMediaKit --WPF项目中 调用摄像头拍照

    <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/200 ...

  9. mac sublime text3-快捷键

    cmd+n 新建页面 cmd+数字键 切换到对应页面 cmd+p 搜索跳转到对应页 cmd+w 关闭页面 cmd+j 合并一行 cmd+d 选中当前单词,继续敲可以选中多个 cmd+l 选中当前行 c ...

  10. 如何快速的开发一个完整的iOS直播app(编解码原理)

    为什么要编码 编码就是压缩图像 手机摄像头采集的都是一帧一帧的图片,只要每秒采集了24帧,看起来就比较流畅,视频就是由一帧一帧的图片构成的,常见图片格式png,jpg,一张图片2M,一秒钟30帧,那么 ...