The problem is SendMessage
has 2 overloads, one which takes a string
type as the last parameter and one that takes an Action<Twilio.Message>
. You are passing null
for this which is acceptable for both of these types, however, confuses the compiler because it can't quite work out which method you want it to call.
For example, if you passed an empty string as the last parameter e.g.
twilio.SendMessage("+441618504425", "07914164512", "code is 123456", null, "");
Then the compiler would know that you want the overload with the string
parameter at the end, not the one with an Action<Twilio.Message>
. Alternatively, if you passed an empty Action<Twilio.Message>
parameter e.g.
twilio.SendMessage("+441618504425", "07914164512", "code is 123456", null, (msg) => {});
Then it would know that you want the call which takes an Action<Twilio.Message>
parameter and not a string
.
Finally, I believe this error
Cannot assign void to an implicitly-typed local variable
Is because SendMessage
doesn't actually return anything. To fix, just change
var message = twilio.SendMessage(...);
To
twilio.SendMessage(...);