c.f. 인터페이스
using System;
delegate void SampleDelegate();
class DelegateClass
{
public void DelegateMethod()
{
..
}
}
class DelegateApp
{
public static void Main()
{
DelegateClass obj = new DelegateClass();
SampleDelegate sd = new SampleDelegate(obj.DelegateMethod);
// or SampleDelegate sd = obj.DelegateMethod;
sd(); // invoke obj.DelegateMethod() indirectly
}
}
class Test
{
public delegate void Handler(string msg);
public event Handler Event;
/* c.f.
private Handler _Event;
public event Handler Event
{
add
{
lock(this) { _Event += value; }
}
remove
{
lock(this) { _Event -= value; }
}
}
*/
public void DoIt()
{
Event("..");
}
}