Do event handlers have to be static?

Supporting Visual Studio on Windows
wamund
Fresh meat
Posts: 1
Joined: Wed Dec 23, 2020 2:34 pm
Contact:

Do event handlers have to be static?

Postby wamund » Wed Dec 23, 2020 2:51 pm

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: 3218
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Do event handlers have to be static?

Postby Patrick » Mon Jan 04, 2021 11:27 am

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

-Patrick


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 2 guests