Do event handlers have to be static?

.NET and C# language support on Windows, macOS and Linux
Post Reply
wamund
Fresh meat
Posts: 1
Joined: Wed Dec 23, 2020 2:34 pm
Contact:

Do event handlers have to be static?

Post by wamund »

In the code examples provided the event handlers are declared as static.
Since I am quite new to C# this proves to be an issue for me, having to reference non-static methods or variables from the event handler method.

So, do event handlers have to be static?

/Mikael
User avatar
Patrick
Lead Developer
Posts: 660
Joined: Mon Jun 20, 2005 8:46 am
Location: Calgary
Contact:

Re: Do event handlers have to be static?

Post by Patrick »

No they don't need to be static - it's just that the main() function is static in the examples.

-Patrick
Post Reply