سؤال


I look around the internet and find thing called Action that can execute void methods, if those voids are stores in variables.

void push(Action <string> action, string methodURL) {
if (methodURL != "123")
action(methodURL);
}

In this case, action is a method to execute and methodURL is it's future argument.

So, I expected to use this code something like that :

push(GetGroups(curTarget), GroupsXML);

GroupsXML is a string and GetGroups is a void with a string argument

and Visual Studio is showing me an error :

1.)Converting "void" to "action"

2.)Too much arguments

هل كانت مفيدة؟

المحلول

Don't need to put stuff in brackets. C# is smart enough to work out and create the action for you.

push(GetGroups, GroupsXML);

Will dynamically convert it to an action

The code you have posted doesn't make so much sense though, you are only specifying one parameter into the action, yet you have two floating about curTarget and methodURL.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top