Convert IEnumerable from one type to another generic type - CSharp System.Collections

CSharp examples for System.Collections:IEnumerable

Description

Convert IEnumerable from one type to another generic type

Demo Code

// The MIT License
using System.Text;
using System.Collections.Generic;
using System;//  ww  w  .j  av a2  s .  c  o m

public class Main{
        public static IEnumerable<TOutput> Convert<TInput, TOutput>(IEnumerable<TInput> input, Converter<TInput, TOutput> converter)
        {
            foreach(TInput inputValue in input)
                yield return converter(inputValue);
        }
}

Related Tutorials