Appends the given values to the end of arr - CSharp System

CSharp examples for System:Array Element Add

Description

Appends the given values to the end of arr

Demo Code


using System.Collections.Generic;
using System;//  w w  w  .  ja va 2  s . c o m

public class Main{
    /// <summary>
      /// Appends the given values to the end of arr
      /// </summary>
      /// <returns>The index at which it was added</returns>
      public static void Concat<T>(ref T[] arr, T[] values)
      {
         var oldLen = arr.Length;
         Array.Resize(ref arr, oldLen + values.Length);
         Array.Copy(values, 0, arr, oldLen, values.Length);
      }
}

Related Tutorials