CSharp examples for System:Array Convert
Convert a collection to an array
using System.Text; using System.Collections.Generic; using System;/*from www . j a v a2 s. com*/ public class Main{ /// <summary> /// Convert a collection to an array /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection"></param> /// <returns></returns> public static T[] ToArray<T>(ICollection<T> collection) { T[] result = new T[collection.Count]; int index = 0; foreach (T item in collection) result[index++] = item; return result; } }