1
所以基本上我已經聲明瞭數組INT存在[,]的地方,但是當我嘗試將值賦給它變成了形式加載,它說,它命名爲「地方」並不在當前的背景下
不會在目前情況下
存在......我不能爲我的生命找出原因。
int pbNum = 0;
int stepFrame = 0;
int stepLeft;
int[,] place;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Player.Location = new Point(100,Ground.Top - 64);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
foreach (var pb in this.Controls.OfType<PictureBox>())
{
place(0, pbNum) = pb.Left;
pbNum += 1;
}
this.Text = pbNum.ToString();
}
1)你沒有初始化該變量的函數,但陣列; 2)使用方括號:place [0,pbNum] = ... – JleruOHeP
@ Tanruss1 [那你爲什麼要像使用方法一樣使用數組?](https://msdn.microsoft.com/en-us/library /2yd9wwz4.aspx) – Prix
@JleruOHeP謝謝,我還不太習慣c#,這是我第一次上課 – Tanruss1