I'm getting the following error: "cannot use a method group as an argument to a dynamically dispatched operation" on:
public static void Convert(dynamic o)
{
clsQRcode.ConvertToQRs(o, SendSignalR); // error is here
}
public static void SendSignalR(dynamic o)
{
.... do stuff ....
}
In clsQRcode.ConvertToQRs:
public static void ConvertToQRs(dynamic o, Action<dynamic> SSR)
{
... do stuff to o
SSR(o);
}
So, what am I don't wrong?
CHANGED CODE:
I removed all references to dynamics and now have the following code with a similar error:
public static void ConvertToQRs(string jsonString)
{
clsQRcode.ConvertToQRs(jsonString, SendSignalR); // error still here
}
public static string SendSignalR(string org_int, string person_int, string code, string message, string sCode = "")
{
... do stuff ...
}
Changed clsQRcode to:
public static void ConvertToQRs(string jsonString, Func<string, string, string, string, string> SSR)
{
... do the work ...
SSR(org_int, person_int, function, message);
}
But now the error message is: "cannot convert from 'method group' to 'Func
Look at this line in your final code:
public static string SendSignalR(string org_int, string person_int, string code, string message, string sCode = "")
This method accepts 5 string
parameters and returns string
too, so it's Func<string, string, string, string, string, string>
(first 5 string
- types of input parameters, last one - type of return value), while here
public static void ConvertToQRs(string jsonString, Func<string, string, string, string, string> SSR)
SSR
is Func<string, string, string, string, string>
(note, only 5 string
, not 6). Replace this line with
public static void ConvertToQRs(string jsonString, Func<string, string, string, string, string, string> SSR)
(6 string
) and your code will work.