Combine two byte array - CSharp System

CSharp examples for System:Byte Array

Description

Combine two byte array

Demo Code


using System.Text;
using System;//from  w  w  w  .j  ava  2s .  co  m

public class Main{
        public static byte[] Combine(this byte[] array, params byte[] bytes)
        {
            if (array == null || array.Length == 0)
            {
                return bytes ?? new byte[0];
            }
            if (bytes == null || bytes.Length == 0)
            {
                return array ?? new byte[0];
            }
            var result = new byte[array.Length + bytes.Length];
            Array.Copy(array, result, array.Length);
            Array.Copy(bytes, 0, result, array.Length, bytes.Length);
            return result;
        }
}

Related Tutorials