delegate and event
using System;
public delegate void EventHandler(int i);
class MainClass
{
static void Main(string[] args)
{
MyEventPublisher EventPublisher = new MyEventPublisher();
EventHandler MyAnonymousDelegate = delegate(int x)
{
Console.WriteLine("Anonymous Event FIRED!");
};
EventPublisher.MyEvent += MyAnonymousDelegate;
EventPublisher.DoSomething();
}
}
public class MyEventPublisher
{
public event EventHandler MyEvent;
public int DoSomething()
{
MyEvent(5);
return 0;
}
}
Output Anonymous Event FIRED!
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
|