'string[]' does not contain a definition for 'Cast'

c#

Solution

(1) Make sure you are working on C# 3.0+

(2) Make sure your code contains:

using System.Linq;

(3) `.Cast` is a generic method, you need to specify the type parameter, like this:

return mNames.Cast<AnotherType>().ToArray();

Problem

I am getting the error: 'string[]' does not contain a definition for 'Cast' and no extension method 'Cast' accepting a first argument of type 'string[]' could be found (are you missing a using directive or an assembly reference?) on the following piece of code: ``` return mNames.Cast().ToArray(); ``` What using directive or assembly reference do I need? How do I find out such things? I'm a noob at C# and .NET, I'm just copying code to get a job done, so don't get too technical with me.

Original source