A long name, but I wanted it to be specific. The title is really a question. Although the method called by InvokeMember
has an out
parameter and assigns a value to this parameter, I cannot capture this value. Here is the code I originally used:
string parameter = ""; int result = Convert.ToInt32(typeof(Ability).InvokeMember(selectedMove, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, new object[] { parameter }));
I changed it, which now does its intended work, but I do not know why:
object[] args = new object[1]; //necessary to retrieve ref/out parameter int result = Convert.ToInt32(typeof(Ability).InvokeMember(selectedMove, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, args));
source share