Yes, but in the loop body you're treating it as it was an index, which is expected to be of integer type not of Tile type, hence the error. x should be directly used as a Tile object. When you iterate through a collection in this manner your iterator variable represents the object itself, not its index. Note that you even declared it as such in the foreach statement (Tile x)
foreach(Tile x in allTiles){
if (x.Position == position && x.hasBuilding == false){
return x;
}
}
Of course, some name other than x would be more suitable here.