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