AGENT.Contrib.Hardware.Bluetooth.Connection.CombineArrays C# (CSharp) Method

CombineArrays() private static method

Append source to the end of destination Resize or new up destination if needed. We assume that destination is full, so no need to keep track of the last byte used, just extend and copy source into
private static CombineArrays ( byte source, byte destination ) : byte[]
source byte
destination byte
return byte[]
        private static byte[] CombineArrays(byte[] source, byte[] destination)
        {
            int destPointer = 0;
            //if we are starting with nothing in our destination, lets new it up with the same size as our source length
            if (destination == null)
            {
                destination = new byte[source.Length];
            }
            else
            {
                //destination already has data
                destPointer = destination.Length;
                //lets create a new buffer, that can handle both sets of data
                var newDest = new byte[source.Length + destination.Length];
                //copy destination into the first bytes of the newly allocated array
                destination.CopyTo(newDest, 0);
                //set destination to our larger buffer
                destination = newDest;
            }

            //push the source bits into the trailing slots of our final destination
            source.CopyTo(destination, destPointer);
            return destination;
        }