Missing Reference
Hello,
I'm attempting to work through some sample code that reads data from a CSV file.
However, when I run the query I receive the following error message;
'System.Collections.IEnumerable' does not contain a definition for 'Skip' and no extension method 'Skip' accepting a first argument of type 'System.Collections.IEnumerable' could be found (press F4 to add a using directive or assembly reference)
Naturally I pressed F4 to add a reference but I can't seem to find one that satisfies this error.
Can someone please point me in the right direction?
Many thanks in advance,
~ Dave
I'm attempting to work through some sample code that reads data from a CSV file.
However, when I run the query I receive the following error message;
'System.Collections.IEnumerable' does not contain a definition for 'Skip' and no extension method 'Skip' accepting a first argument of type 'System.Collections.IEnumerable' could be found (press F4 to add a using directive or assembly reference)
Naturally I pressed F4 to add a reference but I can't seem to find one that satisfies this error.
Can someone please point me in the right direction?
Many thanks in advance,
~ Dave
Comments
Any thoughts?
Thanks,
~ Dave
The problem is that you're trying to use a LINQ query operator on a non-generic collection. You need to first apply the Cast or OfType query operator to obtain a generic IEnumerable.
Thank you, that worked!
I changed the example I was following from this;
var csvData = from row in MyExtensions.ReadFrom(@c:\1900.csv).Skip(1)
let columns = row.Split(',')
select new
{
Year = int.Parse(columns[0]),
Make = columns[1],
Model = columns[2],
Trim = columns[3]
};
csvData.Dump();
************************************************
To this;
IEnumerable query = MyExtensions.ReadFrom(@c:\1900.csv).OfType();
var csvData = from row in query.Skip(1)
let columns = row.Split(',')
select new
{
Year = int.Parse(columns[0]),
Make = columns[1],
Model = columns[2],
Trim = columns[3]
};
csvData.Dump();
Now I'm in business playing... oh, I mean working... on some queries.
Thanks again!
~ Dave