There are several arrays

int[] array1 = { 1, 0, 1, 0, 0 }; int[] array2 = { 0, 0, 1, 1, 0 }; int[] array3 = { 1, 1, 1, 0, 1 }; 

how to add them and get one with 15 elements

 int[] array4 = { 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1 }; 

    2 answers 2

    Enumerable.Concat Combines two sequences:

     var result = array1.Concat(array2.Concat(array3)); 
    • 'System.Array' doesn’t contain a definition for Conc Concat ’and no extension method Conc System.Array could can I find it using sharpdevelop , but not VS, does it affect somehow? - johniek_comp
    • add using System.Linq; - Specter

    Probably something like this:

     int[] array4 = new int[array1.length + array2.length + array3.length]; array1.CopyTo(array4, 0); array2.CopyTo(array4, array1.length); array3.CopyTo(array4, array1.length + array2.length);