Extract Subset from Array - CSharp System

CSharp examples for System:Array Operation

Description

Extract Subset from Array

Demo Code


using System.Text;
using System.Collections;
using System;/* w  w w  . j a v  a2s  . co  m*/

public class Main{
        // create a subset from a range of indices
        public static T[] ExtractSubset<T>(this T[] array, int startIndex, int length)
        {
            T[] subset = new T[length];
            Array.Copy(array, startIndex, subset, 0, length);
            return subset;
        }
}

Related Tutorials