Why can I not call ToArray on a generic IEnumerable object?
arrays, c#
Solution
Assuming you're on .NET 3.5 or later, you need to add the `using` directive to the top of your code file:
using System.Linq;
You also need to have an assembly reference to `System.Core` (although this should be there by default for Visual Studio projects).
Problem
``` public static T[] ToArray<T>(IEnumerable<T> e) { return e.ToArray(); } ``` I get the following compiler error: Error 1 `System.Collections.Generic.IEnumerable<T>` does not contain a definition for `ToArray` and no extension method `ToArray` accepting a first argument of type `System.Collections.Generic.IEnumerable<T>` could be found (are you missing a using directive or an assembly reference? But the MSDN reference lists this method. What is wrong here?