public byte[] toArray() {if (arrays.isEmpty()) {return null;} else if (arrays.size() > 1) {int totalLength = 0;for (byte[] array : arrays) {totalLength += array.length;}byte[] concatenated = new byte[totalLength];int destPos = 0;for (byte[] array : arrays) {System.arraycopy(array, 0, concatenated, destPos, array.length);destPos += array.length;}arrays.clear();arrays.add(concatenated);}return arrays.get(0);}
public byte[] ToArray(){if (arrays.Count==0){return null;}else if (arrays.Count > 1){int totalLength = 0;foreach (byte[] array in arrays){totalLength += array.Length;}byte[] concatenated = new byte[totalLength];int destPos = 0;foreach (byte[] array in arrays){Array.Copy(array, 0, concatenated, destPos, array.Length);destPos += array.Length;}arrays.Clear();arrays.Add(concatenated);}return arrays[(0)];}