using System; using System.Collections.Generic; using System.Text; namespace DelegatePassing { class Program { public delegate void MyDelegate( int value ); public event MyDelegate EventDelegate; static void Main( string[] args ) { Program p = new Program(); p.EventDelegate += new MyDelegate( p_EventDelegate ); p.EventDelegate += new MyDelegate(o_EventDelegate); TestEventPassing( p.EventDelegate, 12 ); } static void p_EventDelegate( int value ) { Console.WriteLine( "P is passing {0} from event.", value ); } static void o_EventDelegate( int value ) { Console.WriteLine( "O is passing {0} from event.", value ); } static void TestEventPassing( MyDelegate deleg, int value ) { if( deleg is MyDelegate ) ( ( MyDelegate )deleg ).Invoke( value ); } } }