嗨,我正在尝试在 Visual Studio 上编写 ac# 应用程序。我在 main 中创建了一个数组,我试图在表单上的单击事件中访问它,但它告诉我当前上下文中不存在数组“字符”。我尝试将数组传递给表单,但我仍然遇到同样的问题。任何帮助将不胜感激这是我的代码。
namespace WindowsFormsApplication10
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool[][] characters = new bool[27][]; // my array characters
characters[1][0] = true;
Application.Run(new Form1());
}
}
}
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
int cs1 = 0,cs2=0;
public Form1()
{
InitializeComponent();
}
public void pictureBox1_Click(object sender, EventArgs e)
{
if (characters[1][0] == true) // trying to access member of characters
{ // array but characters does not
// exist in the current context
pictureBox28.Visible = false;
}
}
}
}