Combine two dimensional array to one dimensional array - CSharp System

CSharp examples for System:Array Dimension

Description

Combine two dimensional array to one dimensional array

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/* w ww . j  av  a  2s .c om*/

public class Main{
        public static byte[] Combine (params byte[][] arrays)
        {
            byte[] rv = new byte[ arrays.Sum (a => a.Length) ];
            int offset = 0;
            foreach (byte[] array in arrays) {
                System.Buffer.BlockCopy (array, 0, rv, offset, array.Length);
                offset += array.Length;
            }
            return rv;
        }
}

Related Tutorials