ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


Converts all elements in an enumerable list from the its to a destination type by calling a provided conversion function


public IEnumerable<TDestination> Convert<TSource, TDestination>(this IEnumerable<TSource> source, Func<TSource, TDestination> conversionFunc)
			foreach (TSource element in source)
				yield return (conversionFunc(element));


List<string> s = ...;
IEnumerable<int> = s.Convert(s => Convert.ToInt32(x));

Author: Ricardo Peres

Submitted on: 30 jan. 2012

Language: C#

Type: System.Collections.Generic.IEnumerable<T>

Views: 4793