c# - Can't use int array from Form1 in Form2 -


i have int array in form1 need use in form2. when i'm trying use array values in form2, gives me zeros.

private void button1_click(object sender, eventargs e) {     frm1 = new form1();      (int = 0; < 26; i++)      {        label1.text += frm1.thecode[i];     } } 

http://i59.tinypic.com/b4cf2b.png http://i59.tinypic.com/b4cf2b.png

but when try same thing in form1, works great!

private void button5_click(object sender, eventargs e) {    frm2 = new form2();     (int = 0; < 26; i++) frm2.label1.text += thecode[i]+ " ";     frm2.show(); } 

http://i59.tinypic.com/jujthi.png http://i59.tinypic.com/jujthi.png

but still need use array in form2, not form1

in form1 must declare int array static field , public in order access form.

so how declare thecode in form1

public static int[] thecode; // should public , static 

and how use array in form2

private void button1_click(object sender, eventargs e) {     // no need create new instance of form1.     (int = 0; < 26; i++)      {        label1.text += form1.thecode[i]; // use static field     } } 

Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -