c# - Main is a 'type' but is used like a 'variable' -


basically, attempted use code found stackoverflow associated colision detection wanted between pictureboxes. however, encounter error stating form name type used variable. code here:

foreach (control picturebox in main) {     if (player.bounds.intersectswith(picturebox.bounds))     {      } } 

in foreach loop. underlining word main, stating these exact words:

'namespace.main' 'type' used 'variable' 

main class. can't iterate on class, have iterate on object. (in case), have iterate on collection of control objects. think maybe wanted:

foreach (control picturebox in controls) 

here, i'm iterating on controls property of current object. assuming doing inside instance of main. otherwise, need reference form object , use:

foreach (control picturebox in myformobject.controls) 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -