I am working with multi-dimentioned arrays of bool
, int
, and various struct
. The code loops through these arrays and performs some operation on specific values. For instance,
for (int x = 0; x < this.Size.Width; x++) {
for (int y = 0; y < this.Size.Height; y++) {
if (this.Map[x, y]) {
DrawTerrain(this.Tile[x, y].Location, Terrain.Water);
}
}
}
I can do simple LINQ stuff, but I can't do what I would like. What I would like to do is use LINQ. Maybe something like
from x in this.Map where x == true execute DrawTerrain(...)
But, I don't understand how I can get the x and y locations or how to call a method in the LINQ statement.
Also, it would be great if I can put this code into a function and be able to call it with a delegate or a predicate? I don't know if delegate or predicate are the correct words.
void Draw(Delegate draw, bool[,] map, struct[,] tiles)
from x in map where x == true draw(titles[x,y]).invoke;
}