Reputation: 1767
I have a delegate function that does a callback. What I want to do is the following:
delegate void someDelegate( int i );
callFunction( int i, someDelate del )
{
del.invoke( i );
}
callFunction( 10, void( int i )
{
printf( i );
} );
I know this is possible but I cannot find it anymore.
Upvotes: 0
Views: 74
Reputation: 6766
Is lambda syntax like this what are you looking for?
class Program
{
static void Main(string[] args)
{
callFunction(10, (i) =>
{
//printf( i );
});
}
public delegate void someDelegate(int i);
public static void callFunction(int i, someDelegate del)
{
del.Invoke(i);
}
}
Upvotes: 4