Usually when people get a "No overload for 'onTimer' matches delegate 'ElapsedEventHandler'" error, it's due to not including the ElapsedEventArgs parameter in the void that runs every time the timer has elapsed. Also, the error seems to disappear when I copy and paste the code into a file that's outside of the solution, so I'm confused. Does anybody know a simpler way to fix this?
static void setTimer()
{
yearIncreaser.Elapsed += onTimer;
yearIncreaser.Enabled = true;
yearIncreaser.AutoReset = true;
}
static void onTimer(Object source, ElapsedEventArgs e)
{
currentYear++;
}
EDIT: Yes, the official error message that the debugging screen produces is: error CS0123: No overload for 'onTimer' matches delegate 'ElapsedEventHandler'
EDIT2: The solution was changing yearIncreaser.Elapsed += onTimer; into a lambda: yearIncreaser.Elapsed += (sender, args) => { }