Cast IEnumerable To Array - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Cast IEnumerable To Array

Demo Code


using System.Linq;
using System.Collections.Generic;

public class Main{
        public static T[] CastOrToArray<T>(this IEnumerable<T> source)
        {//w w w. j  a v a2  s .co m
            return source as T[] ?? source.ToArray();
        }
}

Related Tutorials