I am trying to make a method to enumerate any *enum*, by returning a list containing each constant name and value.

Here's my code:

```
Type enumType = typeof(SomeEnum);
var enumConstants = 
    Enum.GetValues(enumType).
         Cast<enumType>().
         Select(x => new { Value = (int) x, Name = x.ToString() });

```

(I declare `enumType` in this snippet but it is in fact declared in my method signature as `MyMethod(Type enumType)`. I am not showing my method signature because that would require to introduce some *struct* I am using, which is not relevant to the problem here)

The problem is that this code does not compile and I am getting on the `Cast<enumType>().` line the following error:

> 
> The type or namespace name 'enumType' could not be found (are you missing a using directive or an assembly reference?)
> 
> 
> 

I don't understand how can `enumType` be unknown, I just declared it on the previous line!

Note that on the `Enum.GetValues(enumType).` line, there is no error flagged.

Am I missing something here? Is some LINQ playing tricks?