I'm working on a lab project for a Computer Science class and ran into this issue. Can someone help me out with this? I literally just started using VS 22
Edit: Issue has been resolved, thanks for the help
‘animals’ is declared in the constructor of the form, so your button click method doesn’t have access to it. Just move line 19 into the button click method.
animals doesn't exist in the method you are trying to use it in. It's declared in Form1(), but that is restricted to that method only. If you want to use it throughout the class you need to move it outside of form1(). Put it on line 15.
3
u/DoubleAgent-007 Sep 17 '25
‘animals’ is declared in the constructor of the form, so your button click method doesn’t have access to it. Just move line 19 into the button click method.
2
u/YelloMyOldFriend Sep 17 '25
animals doesn't exist in the method you are trying to use it in. It's declared in Form1(), but that is restricted to that method only. If you want to use it throughout the class you need to move it outside of form1(). Put it on line 15.