So here I'm trying to pass a method with a random signature to Foo method. But without any luck.
The thing is that I can pass any action. But on a method.
Any help?
class Bar
{
void M1(int a) { }
void M2(string a, int b) { }
Action<string, int, bool> A1 = (s, i, b) => {};
Action<int, float> A2 = (i, f) => {};
void Foo(Delegate f) {}
void Test()
{
Foo(A1);
Foo(A2);
// Foo(M1); // nope
// Foo(M2); // no way
}
}
PS. I'm trying to get this working under Unity3d's Mono.
M1andM2are "method groups" not delegates. A method group can be converted to any compatible delegate type, and the the compiler refuses to pick one out of the air (like theActionorFunctypes).