Prepend two array - CSharp System

CSharp examples for System:Array Operation

Description

Prepend two array

Demo Code


using System.Diagnostics.Contracts;
using System;//w  w w.j a  v  a2 s.  c  om

public class Main{
        public static T[] Prepend<T>(this T[] x, T[] data)
        {
            Contract.Assert(x != null && data != null);
            int combined = x.Length + data.Length;
            var dst = new T[combined];
            Array.ConstrainedCopy(data, 0, dst, 0, data.Length);
            Array.ConstrainedCopy(x, 0, dst, data.Length, x.Length);
            return dst;
        }
}

Related Tutorials