I want to use Linq to query a 2D array but I get an error:
Could not find an implementation of the query pattern for source type ‘SimpleGame.ILandscape[,]’.
‘Select’ not found. Are you missing a reference to ‘System.Core.dll’ or a using directive for ‘System.Linq’?
Code is following:
var doors = from landscape in this.map select landscape;
I’ve checked that I included the reference System.Core and using System.Linq.
Could anyone give some possible causes?
In order to use your multidimensional array with LINQ, you simply need to convert it to
IEnumerable<T>. It’s simple enough, here are two example options for queryingEach syntax will convert the 2D array into an
IEnumerable<T>(because you sayint itemin one from clause orarray.Cast<int>()in the other). You can then filter, select, or perform whatever projection you wish using LINQ methods.