ProcessBookDelegate(Book book);
Del( s); TestClass { Hello( s) { System.Console.WriteLine(, s); } Goodbye( s) { System.Console.WriteLine(, s); } Main() { Del a, b, c, d; a = Hello; b = Goodbye; c = a + b; d = c - a; System.Console.WriteLine(); a(); System.Console.WriteLine(); b(); System.Console.WriteLine(); c(); System.Console.WriteLine(); d(); } }
(System.Object o, System.EventArgs e) { System.Windows.Forms.MessageBox.Show(); };
Del( x); Del d = ( k) { };
StartThread() { System.Threading.Thread t1 = System.Threading.Thread (() { System.Console.Write(); System.Console.WriteLine(); }); t1.Start(); }
Mammals{} Dogs : Mammals{} Program { Mammals HandlerMethod(); Mammals FirstHandler(){ ;} Dogs SecondHandler(){ ;} Main() { HandlerMethod handler1 = FirstHandler; HandlerMethod handler2 = SecondHandler; } }
Form1() { InitializeComponent(); lastActivity = System.DateTime(); .textBox1.KeyDown += .MultiHandler; .button1.MouseClick += .MultiHandler; } MultiHandler( sender, System.EventArgs e) { lastActivity = System.DateTime.Now; }
Del<T>(T item); Notify( i) { } Del<> m1 = Del<>(Notify);
> m2 = Notify;
Stack<T> { T[] items; index; StackDelegate(T[] items); }
DoWork([] items) { } TestStack() { Stack<> s = Stack<>(); Stack<>.StackDelegate d = DoWork; }
StackEventHandler<T, U>(T sender, U eventArgs); Stack<T> { StackEventArgs : System.EventArgs { } StackEventHandler<Stack<T>, StackEventArgs> stackEvent; OnStackChanged(StackEventArgs a) { stackEvent(, a); } } SampleClass { HandleStackChange<T>(Stack<T> stack, Stack<T>.StackEventArgs args) { } } Test() { Stack<> s = Stack<>(); SampleClass o = SampleClass(); s.stackEvent += o.HandleStackChange; }