• Advertisement
Sign in to follow this  

[C#] - How to set a array to 0?

This topic is 4677 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

How me get all pla = 0?
public class World
{
	public int[,] pla;

	public World(int a, int b)
	{
		int[,] pla = new int [a, b];
	}
}

is there any better way than this?
public class World
{
	public int[,] pla;

	public World(int a, int b)
	{
		int[,] pla = new int [a, b];
		for (int x = 0; x < a; x++)
		{
			for (int y = 0; y < b; y++) pla[x, y] = 0;
		}
	}
}

Share this post


Link to post
Share on other sites
Advertisement
If you later want to set all the values to 0 again , there's Array.Clear(Array, int, int).

Regards,
Andre

Share this post


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

  • Advertisement