If you want to initialize the array from the two other arrays and the int
, you could use:
private bool ArrayMaking(int[] array1, int[] array2, int value, out int[] arrays)
{
int size = array1.Length + array2.Length + 1;
arrays = new int[size];
for (int i = 0; i < array1.Length; i++)
arrays[i] = array1[i];
for (int i = 0; i < array2.Length; i++)
arrays[i + array1.Length] = array2[i];
arrays[arrays.Length - 1] = value;
return true;
}
less efficient but more readable using LINQ:
private bool ArrayMaking(int[] array1, int[] array2, int value, out int[] arrays)
{
arrays = array1.Concat(array2).Concat(new[] {value}).ToArray();
return true;
}