I' m missing something here. I 'll be as clear as I can be.
let's say I have this method :
public Task<CustomClass> TestMethod(string one, string two, int three) { throw new NotImplementedException(); } and I want to create a generic method that takes methods like these (through a delegate) and does something.
so let's say that I have this class with a delegate and a generic method:
public static class SomeClass { public delegate T CallbackMethodDelegate<T>(params object[] args); public static void InvokeMethod<T>(CallbackMethodDelegate<Task<T>> method, params object[] args) where T: class { method.Invoke(args); } } my understanding says that T can be a class, so I should be able to do this somewhere in the code :
SomeClass.InvokeMethod<CustomClass>(TestMethod, "one", "two", 3); But I get compile error
CS1503:Argument 1: cannot convert from 'method group' to 'SomeClass.CallBackMethodDelegate<Task<CustomClass>>' I thought it might be an async thing but even if I change the delegate to void I get the same error. Any ideas what I'm missing? Seems like I'm misunderstanding something important about delegates or generics here. Thank you all in advance.
TestMethoddoesn't take a single parameter ofobject[]so you can't use it like that.