I'm looking for the most efficient way to search a large array of a class. I have an array of tiles and need to find them by ID, the only way I've come up with is below although I'm sure there are far quicker ways, probably some kind of Array.Find
, but I'm unsure on the correct syntax. Any help would be greatly appreciated.
class Program
{
public static tiles[,] tile = new tiles[100,100];
static void Main(string[] args)
{
for (int x = 0; x < 100; x++)
{
for (int y = 0; y < 100; y++)
{
if (tile[x, y].ID == 2)
{
// DO SOMETHING
}
}
}
}
}
public class tiles
{
public int _ID;
public int ID
{
get { return _ID; }
set { _ID = value; }
}
}