Search code examples
c#delegatesmethod-group

How to pass one overload of a method group?


Edit: It is my own mistake (combined with some unexpected changes outside). please ignore this post and sorry for inconvenience!

Before I used to just pass this method:

string DoSomething(string)

Now the vendor added another overload like void DoSomething(string, string). I tried to pass the method as a parameter but the compiler complains it cannot convert the method group, which makes sense I guess since DoSomething now has 2 signatures.

The question is, how do I pass just one signature?


Solution

  • I believe you should define your parameters as either Action<string> or Action<string, string> depending on which method you wish to call.

    The Action<T> Delegate