Found that a piece of code in the class does not work, although all the libraries are connected. Attached screenshots:

Inside the program

Inside class

What could be the problem?

  • 2
    and text at the same time insert the code - Grundy
  • The code must be inserted with pictures, and not attached with images. - AK

1 answer 1

Error due to mismatch of method names and namespace properties.

Rename the method and the error will go away.

This is probably not recursion, but simply in the namespace, the Screen class and your Screen method have the same name. And IDE can not understand what you had there lead. Always, before posting a question, hover over a mistake and read what is written there, maybe just a typo.

 class Class1 { public void CreateScreen() { Graphics graph = null; Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); graph = Graphics.FromImage(bmp); graph.CopyFromScreen(0, 0, 0, 0, bmp.Size); bmp.Save("filename.png"); } } 

Good luck in programming!

SeeSharp

  • I'm talking about red wavy lines, they are not in Program , and in Class there is user321409
  • @ user321409 and you read what is written there? - Aqua
  • "Class1.Screen () is a method that is not allowed in this context" in both cases - user321409
  • @ user321409 answer rules - Aqua
  • @ user321409 is always welcome. A check mark on the right, +1 to the answer, too, would not be bad. Good luck! - Aqua