Copy From byte array - CSharp System

CSharp examples for System:Byte Array

Description

Copy From byte array

Demo Code



public class Main{
        // requires destination to be pre-sized
        public static int CopyFrom(this sbyte[] destination, byte[] source, int sourceStartIndex)
        {//ww  w  .  j a  v a 2s. c om
            for (int i = 0; i < destination.Length; i++)
            {
                destination[i] = (sbyte)source[sourceStartIndex++];
            }

            return sourceStartIndex;
        }
        // requires destination to be pre-sized
        public static int CopyFrom<T>(this T[] destination, T[] source, int sourceStartIndex)
        {
            for (int i = 0; i < destination.Length; i++)
            {
                destination[i] = source[sourceStartIndex++];
            }

            return sourceStartIndex;
        }
}

Related Tutorials