1

I have two methods declared

public void MethodA(object o, Action<string> action) { }
public void MethodA(object o, Action<CustomType> action) { }

How can I call these functions using anonymous method? I know I can pass a pointer to a method, but I am interested in doing this using anonymous method? Currently I am getting error "Ambitious call between....."

MethodA(this, c => { }); // how to explicitly say that C is of type CustomType?
Cœur
  • 37,241
  • 25
  • 195
  • 267
Goran
  • 6,328
  • 6
  • 41
  • 86

1 Answers1

4
MethodA(this, (CustomType c) => { });

or if you want to explicitly state the delegate type as Action<CustomType>:

MethodA(this, (Action<CustomType>)(c => { }));
Eren Ersönmez
  • 38,383
  • 7
  • 71
  • 92