How can I pass an array of integer from a button to another one?
Here is more information (the following code is not exactly my original code, but it explains what I’m asking):
private void button1_Click(object sender, EventArgs e)
{
int[,] array1 = new int[pictureBox1.Height, pictureBox1.Width];
int[,] array2 = new int[pictureBox1.Height, pictureBox1.Width];
array2 = binary(array1);//binary is a function
}
private void button2_Click(object sender, EventArgs e)
{
//I need array2 here
}
Now I want to access array2 in button2. How can I do that? What is the best solution?
Thanks in advance.
Looks like whilst first button click you are prepare some data and whilst second button click you are going to use it some how.
You can share an array using class-level variable: