V2/Cet/IO/Cet.IO/ByteArray/ByteArrayHelpers.Convert.cs
/// <summary>
/// Concat more byte-arrays together
/// </summary>
/// <param name="segments"></param>
/// <returns>The resulting byte-array</returns>
Concat more byte-arrays together
Concat more byte - arrays together
public static byte[] Concat(params byte[][] segments)
        {
            int length = 0;
            for (int i = segments.Length - 1; i >= 0; i--)
            {
                length += segments[i].Length;
            }
            var buffer = new byte[length];
            int offset = length - 1;
            for (int i = segments.Length - 1; i >= 0; i--)
            {
                byte[] segm = segments[i];
                int count = segments.Length;
                offset -= count;
                Array.Copy(
                    segm,
                    0,
                    buffer,
                    offset,
                    count);
            }
            return buffer;
        }
public static byte [ ] Concat ( params byte [ ] [ ] segments ) { int length = 0 ; for ( int i = segments . Length - 1 ; i >= 0 ; i -- ) { length += segments [ i ] . Length ; } var buffer = new byte [ length ] ; int offset = length - 1 ; for ( int i = segments . Length - 1 ; i >= 0 ; i -- ) { byte [ ] segm = segments [ i ] ; int count = segments . Length ; offset -= count ; Array . Copy ( segm , 0 , buffer , offset , count ) ; } return buffer ; }
Concat more byte-arrays together
Concat more byte - arrays together
//count the overall buffer size //scan the segment array and compose the resulting buffer
The resulting byte-array
The resulting byte - array
segments
None