由于某种原因,当我将int大小和board数组放入public类时,它给了我2条错误: 第一个是:
字段初始化程序无法引用非静态字段,方法或属性'Form1.textBox1'
和第二个:
字段初始化器无法引用非静态字段,方法或属性'Form1.size'
public partial class Form1 : Form
{
int size = int.Parse(Textbox1.Text)
Button[,] board = new Button[size,size];
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender,EventArgs e)
{
random code that needs the board array
}
private void Form1_Click(object sender,EventArgs e)
{
other random code that need the board array
}