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.
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.