korgan korgan - 25 days ago 8
C# Question

Create class name in one button and send to second button

I try to make a neural network.

I try create one nn with one button and read it on the second but I
don't know how send local variables to second button.

private void pokaz_Click(object sender, RoutedEventArgs e)
{
int[] cos = { Int32.Parse(a1.Text), Int32.Parse(a2.Text), Int32.Parse(a3.Text) };
siecneuronowa net = new siecneuronowa(cos);

}


private void Button_Click_3(object sender, RoutedEventArgs e)
{

for (int i = 0; i < net.wagi.Length; i++)
{
for (int j = 0; j < net.wagi[i].Length; j++)

{
for (int k = 0; k < net.wagi[i][j].Length; k++)
{
diagnoza.AppendText(net.wagi[i][j][k].ToString("R"));
diagnoza.AppendText(" ");

}
diagnoza.AppendText("\r\n");

}

}

}

Answer Source

Declare class lever variable(as member of class):

private siecneuronowa net;

Then in pokaz_Click replace this line:

siecneuronowa net = new siecneuronowa(cos);

by this:

net = new siecneuronowa(cos);

In Button_Click you will get access to same variable that was initialized in pokaz_Click.