CSharp examples for System.Collections:ICollection
Copies a generic ICollection to an array.
using System.Diagnostics; using System.Collections.Generic; using System;/* w ww.ja v a2s .co m*/ public class Main{ //************************************************************************* // Method: CollectionToArray() // /// <summary> /// Copies a generic ICollection to an array. /// </summary> /// /// <param name="collection"> /// Collection that should be copied. /// </param> /// /// <returns> /// An array of the collection's values. /// </returns> //************************************************************************* public static T[] CollectionToArray<T>(ICollection<T> collection) { Debug.Assert(collection != null); T[] aoValues = new T[collection.Count]; collection.CopyTo(aoValues, 0); return (aoValues); } }