Skip And Take from byte array - CSharp System

CSharp examples for System:Byte Array

Description

Skip And Take from byte array

Demo Code


using System.Text;
using System;//  ww w.j  a  v a 2 s . com

public class Main{
        public static byte[] SkipAndTake(this byte[] array, int skip, int take, bool extend = false)
        {
            if (!extend && take > array.Length)
            {
                take = array.Length;
            }
            byte[] result = new byte[take];
            if (extend && take > array.Length)
            {
                take = array.Length;
            }
            if (take == 0)
            {
                return result;
            }
            if (skip == 0)
            {
                Array.Copy(array, result, take);
            }
            else
            {
                Array.Copy(array, skip, result, 0, take);
            }
            return result;
        }
}

Related Tutorials