The delegate, MyDelegate
defines a method that takes an array of objects, but your ShouldMatch
method does not. Suppose you try to pass any parameters to an instance of your delegate like this:
compilerError(someObject, someOtherObject);
If the method compilerError
is bound to does not accept any parameters, what would you expect to happen here?
Try defining your method in a way that matches the delegate signature:
delegate void MyDelegate(params object[] parameters);
static void ShouldMatch(params object[] parameters) {}
MyDelegate noCompilerError = ShouldMatch;
Or you could try wrapping it in a lambda expression, like this:
delegate void MyDelegate(params object[] parameters);
static void ShouldMatch() {}
MyDelegate noCompilerError = (paramArray) => ShouldMatch();