왜 "alarm.AlarmEvent + = new AlarmEventHandler (alarm_Sound);" 내게는C# 알람 설정을위한 간단한 이벤트 처리기
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);
}
전체 소스 코드를 여기에 "개체 참조가 비 정적 필드, 메서드 또는 속성 'AlarmClock.Alarm.alarm_Sound (객체, 경우 System.EventArgs)'필요"제공합니다 Program.cs AlarmEventArgs
"알람 알람 = 새 알람 (new DateTime (2010, 4, 7, 23, 2, 0)); 이미 인스턴스를 만들었습니까? – yeeen
@yeeen : 그런 다음 'alarm.alarm_Sound'를 추가하여 해당 인스턴스를 사용해야합니다. – SLaks
alr을 컴파일 할 수 있습니다. 하지만 작동하지 않습니다. "헤이!"가 인쇄됩니다. 내 AlarmEventArgs 생성자에서 루프를 계속합니다. 이벤트 alarm_Sound가 호출되지 않습니다 ("Ring ring ring"없음), 어떻게됩니까? – yeeen