Join two byte arrays. - CSharp System

CSharp examples for System:Byte Array

Description

Join two byte arrays.

Demo Code

/// Distributed under the Mozilla Public License                            *
using System;/*w w  w .j a  v  a2 s  .  c o  m*/

public class Main{
        /// <summary> Join two arrays.</summary>
        public static byte[] join(byte[] a, byte[] b)
        {
            byte[] bytes = new byte[a.Length + b.Length];
            
            Array.Copy(a, 0, bytes, 0, a.Length);
            Array.Copy(b, 0, bytes, a.Length, b.Length);
            
            return bytes;
        }
        public static byte[] copy(byte[] from, int start, int len)
        {
            byte[] to = new byte[len];
            Array.Copy(from, start, to, 0, len);
            return to;
        }
        public static byte[] copy(byte[] from, int start)
        {
            return copy(from, start, from.Length);
        }
        public static byte[] copy(byte[] from)
        {
            return copy(from, 0);
        }
}

Related Tutorials