IEnumerable As Typed List - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

IEnumerable As Typed List

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;// ww w .j av a  2 s .c om

public class Main{
        public static IList<T> AsTyped<T>(this IEnumerable collection)
        {
            List<T> typedCollection = new List<T>();

            foreach (T item in collection)
            {
                typedCollection.Add(item);
            }
            return typedCollection;
        }
}

Related Tutorials