1

In my program I got an error that "Member 'TestUno.Form1.value' cannot be accessed with an instance reference; qualify it with a type name instead C:\Users\ADL65654\Documents\Visual Studio". I want to access static array from form1 to form3.

form3:   
            byte by1;
            by = ((Form1)this.Owner).value[0]; //Error
form1:
           public static byte[] value = new byte[10];

How can I solve this?

DPM
  • 67
  • 2
  • 14

1 Answers1

2

You have made the variable static. That means all instances of your Form1 class share a single array. There is no such thing as the array of the Form1 instance you have in this.Owner.

You can either access the shared instance of the array by ignoring the instance in this.Owner and using Form1.value[0] or you have to remove the static keyword if every Form1 instance should have it's own value array.

nvoigt
  • 75,013
  • 26
  • 93
  • 142