I created an object in an event, now I want another event to access it. How to do it?
I am doing this in Visual Studio 2010.
I have a form with three button events. The first button creates an object. I want the second button to use the object. How to do it?
public void buttonCreate_Click(object sender, EventArgs e)
{
int size;
int sizeI;
string inValue;
inValue = textBoxSize.Text;
size = int.Parse(inValue);
inValue = comboBoxSizeI.Text;
sizeI = int.Parse(inValue);
Histrograph one = new Histrograph(size, sizeI);
}
public void buttonAddValue_Click(object sender, EventArgs e)
{
int dataV = 0;
string inValue;
inValue = textBoxDataV.Text;
dataV = int.Parse(inValue);
one.AddData(dataV);
}
source
share