我试图使用数组来存储入侵者的空间入侵者游戏,但每次运行代码它冻结,并有我的数组是错误的大小的错误。添加多个pictureboxes从阵列的C#中形成
错误:
An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll
任何人都可以请帮助?以下是我的代码:
class invaders
{
ingame game = new ingame();
PictureBox[] spaceinvaders = new PictureBox[100];
public void spawn(int level)
{
PictureBox invader = new PictureBox();
Bitmap img = (WindowsFormsApplication1.Properties.Resources.SpaceInvader);
for (int n = 1; n == 3 + level; n++)
{
for (int i = 12; i == 493; i = i + 37)
{
invader = new PictureBox();
invader.Size = new Size(12, 12);
invader.Image = img;
spaceinvaders[i] = invader;
spaceinvaders[i].Location = new Point(i, n);
}
}
game.Controls.AddRange(spaceinvaders);
}
}
请给我们具体的错误信息 – Wndrr
在mscorlib.dll中发生未处理的异常'System.OutOfMemoryException' – space482
在哪一行? – Wndrr