using System;
using System.Collections.Generic;
public delegate void MyDelegate<T>( T i );
publicclass DelegateList<T>
{
publicvoid Add( MyDelegate<T> del ) {
imp.Add( del );
}
publicvoid CallDelegates( T k ) {
foreach( MyDelegate<T> del in imp ) {
del( k );
}
}
private List<MyDelegate<T> > imp = new List<MyDelegate<T> >();
}
publicclass MainClass
{
staticvoid Main() {
DelegateList<int> delegates = new DelegateList<int>();
delegates.Add( PrintInt );
delegates.CallDelegates( 42 );
}
staticvoid PrintInt( int i ) {
Console.WriteLine( i );
}
}