"Method name expected" error when trying add a handler method to a delegate - C#

Posted by zakplayyy on Stack Overflow See other posts from Stack Overflow or by zakplayyy
Published on 2013-08-02T15:08:47Z Indexed on 2013/08/02 15:36 UTC
Read the original article Hit count: 127

Filed under:
|
|
|
|

I keep getting the error "Method name expected" when trying add the a method to a delegate. I have a delegate which is invoked when ever my game ends. The function I'm trying to add to the delegate stops a countdown from flashing (the method is in a static class). I've searched about and I'm still unsure why its not working. Here is the line causing the error:

LivesManager.gameEnded += new LivesManager.EndGame(CountdownManager.DisableFlashTimer(this));

The this passes the current form to the method so it can disable the timer flash on the form.

I have added methods from static classes to the same delegate before and it works fine, the only difference is that I'm passing the form as a paramater and then it doesn't like it.

Is there any way to pass the form to the method without the error?

Thanks in advance :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about methods