Convert IEnumerable by Func
//The MIT License (MIT)
//http://arolibraries.codeplex.com/license
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
namespace AroLibraries.ExtensionMethods.Enumerable
{
public static class IEnumerableExt
{
public static IEnumerable<TDestination> Ext_Convert<TSource,TDestination>(this IEnumerable<TSource> enumerable,
Func<TSource, TDestination> converter){
if (enumerable == null)
{
return null;
}
IList<TDestination> items = new List<TDestination>();
foreach (TSource item in enumerable)
{
items.Add(converter(item));
}
return items.AsEnumerable();
}
}
}
Related examples in the same category