zoukankan      html  css  js  c++  java
  • 截取字节数组

      /// <summary>
            /// 截取字节数组
            /// </summary>
            /// <param name="srcBytes">要截取的字节数组</param>
            /// <param name="startIndex">开始截取位置的索引</param>
            /// <param name="length">要截取的字节长度</param>
            /// <returns>截取后的字节数组</returns>
            public byte[] SubByte(byte[] srcBytes, int startIndex, int length)
            {
                System.IO.MemoryStream bufferStream = new System.IO.MemoryStream();
                byte[] returnByte = new byte[] { };
                if (srcBytes == null) { return returnByte; }
                if (startIndex < 0) { startIndex = 0; }
                if (startIndex < srcBytes.Length)
                {
                    if (length < 1 || length > srcBytes.Length - startIndex) { length = srcBytes.Length - startIndex; }
                    bufferStream.Write(srcBytes, startIndex, length);
                    returnByte = bufferStream.ToArray();
                    bufferStream.SetLength(0);
                    bufferStream.Position = 0;
                }
                bufferStream.Close();
                bufferStream.Dispose();
                return returnByte;
            }
    

      

  • 相关阅读:
    CSS常用伪类
    HTML5常用API
    HTML5新技术FormData提交表单数据
    WebPack打包后如何调试
    layui的初体验(layer的使用)
    java数组
    java:注解
    java反射:框架设计的灵魂
    885历年编程题
    2020年专业课编程题
  • 原文地址:https://www.cnblogs.com/chenli0513/p/4366256.html
Copyright © 2011-2022 走看看