C# Simple Event Handler for Setting Alarm
Posted
by yeeen
on Stack Overflow
See other posts from Stack Overflow
or by yeeen
Published on 2010-04-07T16:05:45Z
Indexed on
2010/04/07
16:13 UTC
Read the original article
Hit count: 327
Why does the following line "alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound);" gives me "An object reference is required for the non-static field, method, or property 'AlarmClock.Alarm.alarm_Sound(object, System.EventArgs)'"
public static void Main(string[] args)
{
Alarm alarm = new Alarm(new DateTime(2010, 4, 7, 23, 2, 0));
alarm.Set();
alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound);
}
Full source code here: Program.cs AlarmEventArgs
© Stack Overflow or respective owner