C # binary byte array operation function intercepts byte array subbyte
<summary>//Intercept byte array///</summary>//<param name= "srcbytes" > byte array to intercept </param>//<param name= "StartIndex" > Index of Start intercept </param>//<param name= "Length" > To intercept Byte length </param>////<returns> truncated byte array </returns> public byte[] Subbyte (byte[] srcbytes, int s Tartindex, 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-starti Ndex) {length = Srcbytes.length-startindex;} Bufferstream.write (srcbytes, startIndex, length); Returnbyte = Bufferstream.toarray (); Bufferstream.setlength (0); BufferstreAm. Position = 0; } bufferstream.close (); Bufferstream.dispose (); return returnbyte; } }