Jump to content
  • Advertisement
Sign in to follow this  
kjarli

Array like php to C#

This topic is 3663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!