ConvertAll ICollection to TOut[] with Converter
using System;
using System.Collections.Generic;
using System.Collections;
public static class CollectionUtils
{
public static TOut[] ConvertAll<TIn, TOut>(this ICollection<TIn> collection,
Converter<TIn, TOut> converter)
{
TOut[] res = new TOut[collection.Count];
int i = 0;
foreach (TIn elem in collection)
{
res[i] = converter(elem);
i++;
}
return res;
}
}
Related examples in the same category