Cast List from IEnumerable - CSharp System.Collections

CSharp examples for System.Collections:IEnumerable

Description

Cast List from IEnumerable

Demo Code


using System.Windows;
using System.Collections.Generic;
using System.Collections;

public class Main{
        internal static IEnumerable<TDst> CastList<TSrc, TDst>(IEnumerable<TSrc> src)
        {//from w w w .  java 2s . c o m
            var dst = new List<TDst>();
            foreach (var e in src)
            {
                dst.Add((TDst)(object)e);
            }
            return dst;
        }
        internal static void CastList(IEnumerable<DependencyObject> src, IList dst)
        {
            foreach (var e in src)
            {
                dst.Add(e);
            }
        }
}

Related Tutorials