ICollection To Array - CSharp System.Collections

CSharp examples for System.Collections:ICollection

Description

ICollection To Array

Demo Code


using System.Text;
using System.Collections.Generic;
using System;// w w  w . ja v  a  2  s .  co  m

public class Main{

        public static T[] ToArray<T>(this ICollection<T> collection, Int32 index = 0)
        {
            lock (collection)
            {
                var arr = new T[collection.Count - index];
                collection.CopyTo(arr, index);
                return arr;
            }
        }
}

Related Tutorials