Something like this:
void Foo(Action<int> m)
{
int a = 5;
m(a);
}
void RegularFoo()
{
Foo(val => // Or: Foo(delegate(int val)
{
Console.WriteLine(val);
});
}
Action<T>
is a delegate that takes exactly one argument of a type you specify (in this case, int
), that executes without returning anything. Also see the general C# delegate reference.
For a simple case like this, it's pretty straightforward. However, I believe there are some semantic/technical differences between blocks in Objective-C and delegates in C#, which are probably beyond the scope of this question.