(Moderator)
Registriert seit: 25. Jun 2002
Ort: Hausach
7.640 Beiträge
|
Re: Dieses Delphi-Event in C#?
4. Aug 2006, 10:36
Code:
public delegate void MyEventDelegate(Int32 int1, Int32 int2);
public class TMyClass : Object
{
public event MyEventDelegate MyEvent;
private void SomeProc()
{
MyEvent(2, 5);
}
}
public class Subscriber : Object
{
public TMyClass myclass;
public Subscriber()
{
myclass = new TMyClass();
myclass.MyEvent += new MyEventDelegate(onEvent);
}
private void onEvent(Int32 a, Int32 b)
{
Int32 c = a + b;
}
}
Und noch ein Edit: Nachtrag: http://www.codeproject.com/csharp/eventdrivenmodel.asp
|