Array like php to C#

Started by
2 comments, last by bubu LV 15 years, 4 months ago
I got the following thing in php, how do you write this for arrays in C#?

$x = 100;
$y = 50;
for($i = 0; $i < $x; $i++) {
	for($j = 0; $j < $y; $j++) {
		$array[$i][$j] = new Tile();
	}
}
It will be used like:

if($build == Unit::TANK) {
	if($array[4][10]->isType(Tile::LAND)) && $array[4][10]->hasFactory($owner)) {
		$array[4][10]->addObject(Unit::TANK, $owner);
	}
}
I've tried several things, but it seems php is the only language that uses "arrays" which you can index yourself...
Advertisement
Tile[,] arr = new Tile[x, y];arr[4, 10] = new Tile();arr[4, 10].addObject(...);


[Edited by - bubu LV on December 2, 2008 5:00:03 AM]
How can i init an entire array? like, x = 100, y = 50
Use for loop in same way you use it in php.

This topic is closed to new replies.

Advertisement